/* 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, if the * button is pressed, the led is going do a quick blinking with the following sequence: * 1sec ON > 0.5secs OFF > 1sec ON > 0.5secs OFF > 1sec ON > turn OFF. * * 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, do the blinking sequence for (int i=0; i<=2; i++){ delay(500); // Wait for half a sec digitalWrite(led, HIGH); // Turn led on delay(1000); // Wait for a sec digitalWrite(led, LOW);} // Turn led off } else { digitalWrite(led, LOW);} // If button is not pressed, keep the LED off }