int buttonPin = 7;
void setup() {
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH); // activates internal pulldown and sets pin state to HIGH
Serial.begin(9600);
}
void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
Serial.println("Button is pressed");
}
else{
Serial.println("Button is not pressed");
}
delay(1000);
}