const int pinButton = 2; // Pin 2 as input for the button
const int pinLED = 8; // Pin 8 as output for the LED
void setup() {
pinMode(pinButton, INPUT); // Set pinButton as input
pinMode(pinLED, OUTPUT); // Set pinLED as output
// Activate pull-up resistor
digitalWrite(pinButton, HIGH);
}
void loop() {
if (digitalRead(pinButton) == LOW) { // If button is pressed
digitalWrite(pinLED, HIGH); // Turn on the LED
}
else { // If button is not pressed
digitalWrite(pinLED, LOW); // Turn off the LED
}
}