Back to Parent

Exercise 2

Change the program to blink on and off 5 times then stop for 3 seconds. Each blink should be 0.5s (half-second)

Things got a little bit trickier here - I use a for loop to achieve the 5 times blink.

I create an integer variable cnt and assign it to 5. By using it as a global variable and call it in the loop, I can easily change the times of blink I need without digging through the for loop to change the number. This method will extend to the cloud variable later on.

It should be noted that I put the delay outside the loop (after the loop) as 2500 ms since we already have a 500 ms delay in the last round of the loop. The outcome is shown in the video.


Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0