const int buttonPin = 3; int buttonState = 0; void setup() { Serial.begin(9600); pinMode(buttonPin, INPUT_PULLUP); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { Serial.print(1); delay(1000); } else{ Serial.print(0); delay(1000); } }