We began the session by revising what we learned last week and looking over our previous Arduino code, line by line.
Next, we recreated a circuit from the worksheet which features a 10K Ohm resistor, a pushbutton, an LED, a breadboard and some jumper wires with our Arduino boards. When the button is pressed the LED lights up
We then altered the code to create a version where the button controls the LED in a different capacity. It is interesting that we can leave the circuit the same but we can change the function of the hardware by changing only the code.
We then updated the code further to remove a small bug so that the light stays on when turned on and turns off when pressed again. There is a noise generated by the push of the button which we can counteract within the code to make it much more reliable in its function.
We then created a new more basic circuit and code that allows our LED to fade on and off intermittently.
This session has been an important coding revision and it is very important to understand what your code is doing, line by line. Otherwise you cannot diagnose errors and you won’t have any deeper understanding of what your code is achieving.