/* Push button and led - week 08 - exercice 1 Turns an LED on when the pushbutton is activated and keep it on while it's pressed down. On my card the led is connected to PB3 and the switch to PB4. written 22 March 2021 by A.de Vries for FABACADEMY 2021 */ int buttonState = 0; // the setup function runs once when you press reset or power the board void setup() { pinMode(4, INPUT); // initialize digital pin with switch as an input. //pinMode(3, OUTPUT); // initialize digital pin with LED as an output. // initialize the serial port: Serial.begin(9600); } // the loop function runs over and over again forever void loop() { // read the state of the pushbutton buttonState = digitalRead(4); // check if pushbutton is pressed. if it is, the button state is HIGH if (buttonState == HIGH) { Serial.println("high"); } else { Serial.println("low"); } delay(10); // Delay a little bit to improve performance }