int buttonPin = D1; // Button connected to GPIO 2
int ledPin = D10; // LED connected to GPIO 10
void setup() {
pinMode(buttonPin, INPUT); // Button as input (pull-down handled externally)
pinMode(ledPin, OUTPUT); // LED as output
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read button state
if (buttonState == HIGH) { // Button pressed
digitalWrite(ledPin, HIGH); // Turn LED on
} else {
digitalWrite(ledPin, LOW); // Turn LED off
}
delay(10); // Small debounce delay
}