Tag Archives: Tutorials

Arduino Tutorial 4: Understanding Arduino Variables

In our earlier lessons we would program using “constants” when we needed numbers. For example, if we wanted to set pin 13 to an output, we would use the command:

pinMode(13, OUTPUT);

The problem with using constants like the number 13, if you decided later to use pin 8 instead, you would have to edit every line of code that used that number. It is much better practice to use variables when coding. In this video we show you have to program using variables. We start by doing things the wrong way, using constants, then show you the advantages of using variables.

Hopefully you can see from this video how much better it is, and more efficient to use variables instead of constants. In all the future lessons, we expect you to use variables.