- val = digitalRead(switchPin); // read input value and store it in val
-
- if (val != buttonState) { // the button state has changed!
- if (val == LOW) { // check if the button is pressed
- Serial.println("Button just pressed");
- } else { // the button is -not- pressed...
- Serial.println("Button just released");
+ statoAttuale = digitalRead(switchPin); // read input value and store it in val
+ // delay(20) // riduce leffetto bounce
+ if (statoAttuale != ultimoStato) { // the button state has changed!
+ if (statoAttuale == HIGH) { // check if the button is pressed
+ Serial.println("Bottone premuto");
+ }
+ else { // the button is -not- pressed...
+ Serial.println("Bottone rilasciato");