Data Types in Arduino

Contributors: b_e_n
Favorited Favorite 38


Computers, including the Arduino, tend to be highly data agnostic. At their core, the heart of the device is an arithmetic-logic unit (ALU), which performs (fairly) simple operations on locations in memory: R1+R2, R3*R7, R4&R5, etc. The ALU doesn't care what that data represents to a user, be it text, integer values, floating point values, or even part of the program code.

All of the context for these operations comes from the compiler, and the directions for the context get to the compiler from the user. You, the programmer, tell the compiler that this value is an integer and that value is a floating point number. The compiler, then, is left trying to figure out what I mean when I say "add this integer to that floating point." Sometimes that's easy, but sometimes it's not. And sometimes it seems like it should be easy, but it turns out to yield results you might not anticipate.

This tutorial will cover the basic data types available in Arduino, what they're typically used for, and will highlight the effects of using different data types on the size and performance speed of your programs.

Suggested Reading

You may want to familiarize yourself with a few concepts before we get started: