C++Arduino is based C++, which has large number of variable types available to us, and some special variables tricks that can be a little confusing but also very helpful when programming microcontrollers.
The Rules For Declaring Variable:
Variable names only contain letters, digits, and underscores
Variable names are case sensitive
Variable names do not contain any whitespace and special characters (for example: #, *, % etc).
Variable names must begin with a letter or an underscore.
We can't use Arduino or C++ keywords as a variable name (for example: void, setup, int)
Arduino Variables
int (2 bytes on uno and other ATMEGA based boards, 4 bytes on SAMD boards)
A whole number between -32 768 and the max value is +32 767.
I.e. int x = 22;
...
I.e. Unsigned Int x = 65 500;
Additional C++ Variables
byte
int
uint
long
ulong
double
Floating Point number
I.e. double y = 1.234;
char
Character
I.e. char z = “a”;
String
A collection of characters
I.e. String testString = “Arduino”;
boolean
A binary variable
I.e. boolean state = false; (1 byte) A single byte of storage i.e a value between -128 and +127,
long (4 to 8 bytes) Like an int, but with twice as much storage
double (4 to 8 bytes) Like a float, but with twice as much storage