24th Jan 2021 – Tolu

In the beginning of the lab session we were reminding ourselves of the previous lab and the things we did.

The first task of this weeks lab was to build a circuit that would cause a push button to control a LED using the bread board, Arduino software, switch and resistor. I firstly began by putting all the components in the right place on the breadboard then making sure that my circuit board also had the correct components in the correct place. After doing all this the next step is to put the code into the Arduino software. Making sure that everything is clear and there are no errors. Verify the code and upload the code and check using the switch if the LED is being controlled when you press it. Good for me it worked.

The next task was to use the code that would cause the LED to remain on after the button had been pressed. The code does not really change however it just gives the instruction to Arduino to “store” the value of the integer that keeps the LED on. This is important because without the store function, the LED would not be able to stay on. 0 = LED off and 1 = LED on. The state variable was determining whether the LED was on or off. The end result was that the button worked for me.

Next I used an improved code because there were times that the button was pressed and it wouldn’t register meaning the LED would either not turn on or turn off. The reason for this is because there’s bouncing from the two pieces of metal inside the button. The bouncing is only for a very small distance and happens for a short time, it causes the switch to change between off and on a number of times until the bouncing stops, and Arduino is quick enough to catch this. The outcome still worked for me at times but not consistently so I went ahead to use a code that would help with the bouncing.

The next code was more improved. It wanted to use the change of state (on and off) and keep them so that it was consistent. The main thing in this code was the if state (high and low). This is a point where the code is remembering the previous function. For example if the switch is off, when you press it the LED comes on. Even though it has changed from on to off it remembers the previous state of the LED being off so that when the button is eventually pressed again, the previous remembered function will be applied (The LED turns off).

The next task was Controlling the LED with PWM. Our task was to take advantage of the effect of Persistence of Vision (POV). In the code, by changing delay times if i made the on delay different from the off delay, yI would make the LED brighter by leaving it on for longer, and the LED dimmer by leaving it off or longer. The technique being used here is called pulse-width modulation aka PWM. This is because there is a change in the LED’s brightness by changing the width of the pulse. My end product produced an LED that was dimming and relighting.

Leave a Reply

Your email address will not be published. Required fields are marked *