YouTube doesn't want you know this subscribers secret
Get Free YouTube Subscribers, Views and Likes

Using Arrays with For Loops

Follow
Programming Electronics Academy

FREE Arduino Crash Course
https://bit.ly/get_Arduino_skills

**Want to learn more? Check out our courses!**
https://bit.ly/3EMCjCy

**Get your Free Trial of Altium PCB design Software**
https://www.altium.com/yt/programming...

**Get the code, transcript, challenges, etc for this lesson on our website**
https://bit.ly/3ref0Nv'>https://bit.ly/3ref0Nv

**We designed this circuit board for beginners!**
KitOnAShield: https://amzn.to/3lfWClU

FOLLOW US ELSEWHERE

Facebook:   / programmingelectronicsacademy  
Twitter:   / progelecacademy  
Website: https://www.programmingelectronics.com/
________________________________

I would say that arrays are one of the most useful programming tools available. Every programming language that I'm familiar with, at least, has some form of an array. If you're trying to learn a new programming language, one of the things I would recommend is to get familiar with how to write and manipulate data in arrays. Like, if I was gonna learn a spoken language, like Russian, I'd want to prioritize learning the most common words and phrases first. Well, if I am learning a new programming language, I am gonna spend a ton of time learning how to use arrays in that language because they're just so fundamental. In this video, you're gonna learn how to go through, that is how to iterate through, an array in the Arduino programming language. If you can do it in the Arduino language, then you can also do it in the C and the C++ language. Knowing how to do this opens up a ton of useful possibilities for you as a programmer, and I'd argue, it's really an essential thing to learn about any programming language that you're interested in using. Stay tuned. Subscribe to our YouTube channel to get more videos like this. All right, before I jump in, I just wanna say a huge shout out to Altium for sponsoring this video. If you check out the description, you can get our link to a free trial of their software. All right, so here we are in the Arduino IDE, and I'm gonna write a little bit of code, and then we're gonna talk about it. Basically, this is what I'm gonna do. I am gonna make an array and I'm gonna say, like, "you know what? This array is gonna be filled with sensor readings from some sensor," like maybe, maybe my device is getting a packet of information from some other device, right? And I have no control over that other device. I'm just getting a series of inputs from some other device, and so I'm gonna make an array that kind of, like, mocks out that input, and then what I'm gonna do is I'm gonna iterate through each one of those inputs, and then we'll print it out to the serial monitor. So let's do that. All right, so what have I got here? Well, the first thing I did is I created an array, and this is just like a mockup array. It could be whatever, but this is an array that holds floating point values. The name is called sensorReadings and the size is four. That means it can hold a total of four values. It can never hold more than four. Like, the limit, the size, of this array is established when you first create it. So the size is four, and then I initialize it with four separate values. Now, you don't have to put in the values when you initialize it but in this case, I have. So I've got four floating point numbers that I initialized it with. Now, for this discussion, what's important for us is we understand, like, what the index of these numbers are. So let me just write that out above this, so we can get clearer. So the index value refers to the position of the element in the array. Now, if you're wondering like, "hey, what is this index thing?

CONTINUED...
https://bit.ly/3ref0Nv'>https://bit.ly/3ref0Nv

**About Us:**
This Arduino lesson was created by Programming Electronics Academy. We are an online education company who seeks to help people learn about electronics and programming through the ubiquitous Arduino development board.

**We have no affiliation whatsoever with Arduino LLC, other than we think they are cool.**

posted by hegskyfk0