|
1234567891011121314151617181920212223242526272829303132 |
- #include <Bounce.h>
-
- // This code turns a led on/off through a debounced button
- // Build the circuit indicated here: http://arduino.cc/en/Tutorial/Button
-
- #define BUTTON 2
- #define LED 13
-
- // Instantiate a Bounce object with a 5 millisecond debounce time
- Bounce bouncer = Bounce( BUTTON,5 );
-
- void setup() {
- pinMode(BUTTON,INPUT);
- pinMode(LED,OUTPUT);
- }
-
- void loop() {
- // Update the debouncer
- bouncer.update ( );
-
- // Get the update value
- int value = bouncer.read();
-
- // Turn on or off the LED
- if ( value == HIGH) {
- digitalWrite(LED, HIGH );
- } else {
- digitalWrite(LED, LOW );
- }
-
- }
-
|