Write the code and boot it onto the board with arduino
For this assignment we had to write some code for the board which i created in documentation 6.
First i declared an int LEDCount =8; and boolean ButtonInterrupt = false; to check if the button was pressed or not and to count from one LED to the other ones and to check if the voltage is supposed to be HIGH or LOW in the for loop.
Then i assigned the pins to the button and LEDs and marked them as INPUT or OUTPUT depending if a button or LED. The Button is programmed as INPUT since it takes an input from the user, and OUTPUT for the LEDs
All that code is written in void setup. This code will be run trough only once. Then it goes to void loop. That part of the code is run trough over and over again./p>
In the if part it is checked if when the button is pressed. When it is pressed it checks if the current LED is 10. If that is the case it goes back to pin 8. else it counts +1 to the current LED. Trough this the LED switches. If the Button is not pressed it does nothing. Down in the for loop it loops trough the 3 LEDs and if the variable i is the same number as the pin it must mean that this is the one to light up so it sets it to voltage = HIGH and else to LOW. Lastly there is also a text output showing which LED is glowing.