Back to Parent

Outcome


Exercise 1.1- Make LED Blink on and off every 3 seconds.


The introduced code for the light blinking includes a loop that directs the light to illuminate (digitalWrite(ledPin, HIGH)) for a duration of three seconds (delay(3000)), followed by deactivation (digitalWrite(ledPin, LOW)) for an additional three seconds. As a result, the light alternates between on and off states at three-second intervals. 

Code and video are below

Show Advanced Options
Show Advanced Options

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

 I modified the code by incorporating a nested loop within the loop() function to achieve five cycles of the light blinking on and off. Each blink is separated by a brief pause, and there's an additional 3-second delay after completing the five blinks.  

Code and video are below


Show Advanced Options
Show Advanced Options

Exercise 1.3-  Go back to the original program. Now add a second LED to the circuit.   Program the LED’s to alternate blinks i.e. when LED 1 turns on, LED 2 turns off, then when LED 2 turns on, LED 1 turns off.

I added another Led into the D3 input and then rewrote code 1, where I made them high and low alternatingly, with a small delay in between




Show Advanced Options
Show Advanced Options

Reflection

Labelling the code helped me have a better understanding. Although I am still struggling with the concepts of loops, especially void loops, I think I can better comprehend writing basic code. My code can be longer, but it will get the job done!

Drop files here or click to select

You can upload files of up to 20MB using this form.