// Pin definitions
const int buttonPin = 2; // Connect a push button to pin 2
const int ledPin = 13; // Connect an LED to pin 13
// Variables
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the state of the button
buttonState = digitalRead(buttonPin);
// Turn on the LED if the button is pressed
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}