// Button connected to digital pin D1 const int buttonPin = D1; void setup() { // Initialize serial communication at 115200 baud Serial.begin(115200); // Initialize the button pin as an input with an internal pull-down resistor pinMode(buttonPin, INPUT_PULLDOWN); } void loop() { // Read the digital value from the button int buttonValue = digitalRead(buttonPin); // Print the button state to the serial monitor Serial.print("Button State: "); if (buttonValue == HIGH) { Serial.println("HIGH"); } else { Serial.println("LOW"); } // Wait for a short period before reading the value again delay(1000); }