int buttonpin = 2;
int buttonState = 0;
void setup() {
// put your setup code here, to run once:
pinMode(buttonpin,INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(buttonpin);
if (buttonState == LOW)
{
Serial.println("button pressed");
}
else
{
Serial.println("button not pressed");
}
delay(1000);
}