12345678910111213141516171819202122232425262728293031323334353637 |
- #include <Bounce2.h>
- #define BUTTON_PIN 2
- #define LED_PIN 13
- int ledState = LOW;
- Bounce debouncer = Bounce();
- void setup() {
-
- debouncer.attach(BUTTON_PIN,INPUT_PULLUP);
- debouncer.interval(25);
-
-
- pinMode(LED_PIN,OUTPUT);
- digitalWrite(LED_PIN,ledState);
-
- }
- void loop() {
- debouncer.update();
-
- if ( debouncer.fell() ) {
- ledState = !ledState;
- digitalWrite(LED_PIN,ledState);
- }
- }
|