#define BUTTON_PIN 21
//Variable Will Change
int lastState = HIGH; //The previous state from the input pin
int currentState; //The current reading from the input pin
void setup() {
Serial.begin(115200);
pinMode (BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
//Read the state of the switch/button
currentState = digitalRead(BUTTON_PIN);
if (lastState == LOW && currentState == HIGH)
Serial.println ("The state change from LOW to HIGH");
//Save the last state
lastState =currentState;
}