Loops (for and while)


Let's try and implement some of the programming knowledge we learned earlier with the Engduino, specifically For and While loops

For Loop

Let's begin with a For loop - Since each LED on the Engduino has its own unique ID, we can refer to them via each iteration of a For loop. In this example, we'll make each LED light in sequence, with all the lights turning off at the end:

Let's break it down

Now try modifying this example, here are some exercises to get you started:

While Loop

This example will be a bit different: instead of having each LED turn off (and stay on) in sequence, we will have a perpetual While loop check if the Engduino's button has been pressed, turning the LED's on (or off) if it is pressed:

Let's break it down:

Now try modifying this example, here are some exercises to get you started:

Download pdf:

Click to Download pdf