Arduino Array Intro
Who hasn’t made a list of stuff, like a grocery list or to-do list?
When programming with Arduino, a list of stuff is called an “array“.
Check out this lesson to learn about Arrays:
- What is an array?
- What can I put in an array?
- How do you create an array?
- How do I get an item out of an array?
Intro to arrays
Are you trying to use an array in your Arduino program? Maybe you’ve got some values in an array and you’re trying to print them out. Maybe you have some pin numbers in the array and you’re trying to get each pin to do something like turn an LED on or off or whatever.
The bottom line is that arrays are really useful data structures. They’re common in just about every programming language. So learning how to use them is super important.
What is an array?
All right, so what IS an array? Well, an array is just a list. And lists can be really useful, right? Like a to-do list. An array is just a list of stuff. Now an array is a little more complicated than just say an integer. There’s more going on. And for that reason, it’s called a data structure. 
What can I put in an array?
Well, you can put anything you want in an array. But in Arduino or in C, it needs to be all of this same type of stuff. So if you’re gonna put integers in the array, you have to have a list of integers. You can’t have like an integer and then a floating point number and then a byte. Like they all need to be the same type.
How do you create an array?
Using the Arduino IDE, we’ll go ahead and write out an array.
Finally, at the end of the statement, you need to put a semicolon. In every line of Arduino code or C code, you need to end with a semicolon.
Now if you don’t specify the size when you are creating your array, then the number of elements you put inside the curly braces will be the size of the array. And that’s one important thing to realize with arrays in Arduino. You can’t later increase the size of the array. The size of the array is set once it’s created. You can’t make it bigger, you can’t make it smaller. You can only change what the elements actually are. Which is different from a lot of other programming languages where you can dynamically change the size of the array.


How do I get an item out of an array?
So once you’ve created an array, how would we get an item out of the array? Well, we’re going to do what’s called “indexing”. We’ll write the name of our array, use the square brackets, and then put the number of the index inside it.
See video for an example of using our array to print values to the Arduino serial monitor.

