#include /* DESCRIPTION ==================== Simple example of the Bounce library that switches the debug LED when a button is pressed. */ // Include the Bounce2 library found here : // https://github.com/thomasfredericks/Bounce2 #include #define LED_PIN 21 // Instantiate a Bounce object Bounce debouncer = Bounce(); void setup() { Serial.begin(115200); // After setting up the button, setup the Bounce instance : debouncer.attach(T7); debouncer.interval(5); // interval in ms //Setup the LED : pinMode(21,OUTPUT); } int ledState = LOW; void loop() { // Update the Bounce instance : debouncer.update(); // Get the updated value : int value = debouncer.read(); // Turn on or off the LED as determined by the state : if ( debouncer.fell() ) { // Toggle LED state : ledState = !ledState; digitalWrite(LED_PIN,ledState); } }