Files
thomasfredericks_Bounce2/examples/bounce/bounce.pde
T
2013-12-21 13:34:31 -05:00

33 lines
604 B
Plaintext

#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 );
}
}