#define BUTTON_PIN 4
void setup() {
Serial.begin(115200);
//pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(BUTTON_PIN, INPUT);
}
int lastState = HIGH;
void loop() {
int value = digitalRead((BUTTON_PIN));
if (lastState != value) {
lastState = value;
if (value == HIGH) {
Serial.println(" released");
}
if (value == LOW) {
Serial.println(" pressed");
}
}
}