#define ledPin 2
#define buttonPin 15
int buttonState = 0;
void setup() {
Serial.begin(115200);
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Initialize the push button pin as an input
pinMode(buttonPin, INPUT);
}
void loop() {
// Read the state of the push button
buttonState = digitalRead(buttonPin);
// Check if the push button is pressed
if (buttonState == HIGH) {
// If the push button is pressed, turn on the LED
digitalWrite(ledPin, HIGH);
} else {
// If the push button is released, turn off the LED
digitalWrite(ledPin, LOW);
}
// Small delay for debouncing
delay(50);
}