/* Made by Jefferson Sandoval during the Embedded programming for the FabAcademy2021 * * This is just a simple testing code in Arduino consisting of a button and a led, * the led is going to be On during the time that the butotn is pressed. * * This code was uploaded to a board with an Attiny1614 microcontroller. Documentation: * http://fabacademy.org/2021/labs/kamplintfort/students/jefferson-sandoval/assignments/week09/ */ const int button = 9; // Set number of the button pin const int led = 10; // Set number of the LED pin byte buttonState = 1; // Variable for button status void setup() { pinMode(led, OUTPUT); // Set LED as an output pinMode(button, INPUT_PULLUP); // Set button as an input with PullUp resistors configuration } void loop() { buttonState = digitalRead(button); // Read state of the button value if (buttonState == LOW) // Check if button is pressed { // If button is pressed, Turn on LED digitalWrite(led, HIGH); // Turn led on } else { digitalWrite(led, LOW);} // If button is not pressed, keep the LED off }