//https://roboticsbackend.com/arduino-push-button-tutorial/
#define BUTTON_PIN 3
volatile byte buttonReleased = false;
void buttonReleasedInterrupt() {
buttonReleased = true;
}
void setup()
{
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN),
buttonReleasedInterrupt,
FALLING);
}
void loop()
{
if (buttonReleased) {
buttonReleased = false;
// do something here, for example print on Serial
Serial.println("Button released");
}
}