Skip to content

Latest commit

 

History

History
14 lines (7 loc) · 1.88 KB

eecullen-loops.md

File metadata and controls

14 lines (7 loc) · 1.88 KB

Simple Program

In starting my exploration of a new topic I decided to explore loops. For the first loop, I used a forever loop. In the forever loop, I put “set all pixels block” to blue causing the light on the CPX to change color for one second. It stays blue for one second because the pause block is set to that length of time. After the light on the CPX is blue for one second, the light turns red. After it turns red, it stays red for one second because of the second pause block. The loop that these commands are in is a forever loop and therefore when this program is run it will show blue lights for one second and then red lights for one second and will continue in that pattern indefinitely, or until stopped.

More Complex Program

In order to make my looping program more complex I first switched from a forever loop to a loop that stops after a set amount of times. I set the loop to repeat five times. In order to have the loop repeat only five times it has to be placed in an “on start” block because it cannot run a loop that only runs five times without the on start block. In the loop that runs five times I have the same idea for the program that I used in my simple program. It shows the blue light for a second and then it shows the red light for one second. This program is only run five times though, so after each color displays five times the program stops on its own.

Different Program

In order to make the loops that I have been using more complicated, and also different from what I had done previously I made it so the program can only run when the light level is less than 100. That means that when the CPX is in the dark, then the loop runs 5 times. The loop that runs displays blue lights on the CPX for one second, then red lights on the CPX for one second. If the CPX is taken out of the dark then it the loop stops.

View my loop video