/*
1. Connect LED anode to digital pin (pin 13) on the Arduino board.
2. Connect LED catode to resiston (200-ohm) and the to the ground (GND) of the Arduino board.
3. Connect one leg of the push button to the digital pin (pin 2).
4. Connect the other leg of the push button to the ground (GND) of the Arduino board.
*/
// Define variables
int buttonPin = 2; //
int ledPin = 13; //
bool buttonState = 0;
void setup() {
pinMode(ledPin, OUTPUT); // LED pin as an output.
pinMode(buttonPin, INPUT); // Button pin as an input.
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH){
digitalWrite(ledPin, HIGH); // Turn LED on.
} else {
digitalWrite(ledPin, LOW); // Turn LED off.
}
}