A variable of type int in Arduino C uses 2 bytes of data. Unless a sketch becomes very memory hungry, then ints tend to be used for almost everything, even for Boolean values and small integers that could easily be represented in a single byte value.
| Type | Memory (bytes) | Range | Notes |
| boolean | 1 | true or false (0 or 1) | Used to represent logical values. |
| char | 1 | –128 to +127 | Used to represent an ASCII character code; for example, A is represented as 65. Negative numbers are not normally used. |
| byte | 1 | 0 to 255 | Often used for communicating serial data, as a single unit of data. See Chapter 9. |
| int | 2 | –32768 to +32767 | These are signed 16 bit values. |
| unsigned int | 2 | 0 to 65536 | Used for extra precision when negative numbers are not needed. Use with caution as arithmetic with ints may cause unex- pected results. |
| long | 4 | 2,147,483,648 to 2,147,483,647 | Needed only for representing very big numbers. |
| unsigned long | 4 | 0 to 4,294,967,295 | See unsigned int. |
| float | 4 | –3.4028235E+38 to + 3.4028235E+38 | Used to represent floating point numbers. |
| double | 4 | as float | Normally, this would be 8 bytes and higher precision than float with a greater range. However, on Arduino double is the same as float. |
The data types described in Table all apply to the original Arduinos based on the ATMega family of eight bit microcontrollers. With the advent of new ARM-based 32-bit microcontrollers, both official and compatible, these definitions do not necessarily stand for some devices. For this rea- son, some people prefer to use an alternative and more rigorous set of type definitions.
These are prefixed by the letter “t.” So, for example if you are expecting a 16-bit integer and want to make sure you don’t accidentally get a 32-bit integer, you can define your variable like this:
int16_t myVariable = 0;
To my mind, this looks ugly and makes the code less accessible. So, I only use these data type definitions, if it is critical that I get exactly the number of bits that I need. This is something that does not happen often, because if your variable ends up being bigger than expected because the processor processes that number of bits at a time, then the extra bits will simply be ignored. It only tends to be significant if you are doing some- thing a bit naughty, like relying on an integer to “wrap-around.”