This article details the most common data types used in Arduino programming.
A collection of variables that can be accessed via an index number.
Below are the various methods of declaring arrays:
int myInts: declares an array without initializing it.
int myPins: declares an array without specifying size.
int mySensVals: declares an array and specifies size.
Can hold either a true or false value.
Syntax: bool var = val
Var refers to a variable.
Val is the value you assign to that variable.
A data type used to store a character value.
Character literals, or just letters, are enclosed by single quotes, whereas a collection of characters, also known as a string, uses double quotes.
char myLetter = 'A';
char myInitials = "AL";
Stores an eight bit integer number, from 0-255.
Syntax: byte var = val
'var' and 'val' have the equivalent meaning as they do with respect to the bool data type.
Data type for floating-point numbers, or numbers with decimal points.
Often used to approximate values as they have greater resolution (precision) than integers.
Syntax: float var = val
float pi = 3.14
Floating-point arithmetic takes longer to compute than it would if integers were used.
The float data type has 6-7 digits of precision (note: not digits after the decimal point, but total digits).
Primary data type for number storage.
Syntax: int var = val
Used only in function declarations (ie void loop, void setup)
Void Indicates that the following function is not expected to return any information to the function from which it was called.
For example, although there are actions performed within the void setup and void loop functions, no information is returned to the larger program.
Conversions - converting one data type to another:
byte(x) converts the value x into a byte data type
char(x) converts the value x into a char data type
float(x) converts the value x into a float data type
int(x) converts the value x into an int data type