Data Types in Arduino

Pages

Contributors: b_e_n

Introduction

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:


Want more information about SparkFun's classes? Interested in getting involved with teaching electronics? Just want to talk? Sign up for our newsletter, or contact our education department.

SparkFun is a company built around one core idea – sharing ingenuity. We think everyone should have the hardware and resources to learn and play with cool electronic gadgetry.

Share, give, learn, SparkFun.

Do you regularly instruct classes and workshops in a formal or informal learning environment? SparkFun offers Educator Discounts to people teaching and sharing electronics.

Find out more.