const int buttonPin = 13; // the pin that the button is connected to int buttonState = 0; // variable to store the state of the button void setup() { pinMode(buttonPin, INPUT); // initialize the button pin as an input Serial.begin(9600); // initialize serial communication at 9600 bits per second } void loop() { buttonState = digitalRead(buttonPin); // read the state of the button Serial.println(buttonState); // print the state of the button (0 for LOW, 1 for HIGH) delay(100); // delay to avoid reading the button state too quickly }