const int buttonPin = 10; // Define the pin connected to OUT int buttonState = 0; // Variable to store button state void setup() { Serial.begin(9600); // Start serial communication pinMode(buttonPin, INPUT); // Set button pin as input } void loop() { buttonState = digitalRead(buttonPin); // Read button state if (buttonState == HIGH) { // If button is pressed Serial.println("Button Pressed"); } else { Serial.println("Button Released"); } delay(200); // Small delay to prevent flickering }