Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Bounce is a debouncing (http://en.wikipedia.org/wiki/Debounce#Contact_bounce) library for Arduino (http://arduino.cc) or Wiring (http://wiring.org.co) by Thomas Ouellet Fredericks with contributions from: Eric Lowry, Jim Schimpf and Tom Harkaway.
INSTALL AND IMPORT
Put the "Bounce 2" folder in your Arduino or Wiring "libraries". To identify this location open "menubar-> File -> Preferences".
Select "menubar -> Sketch -> Import Library -> Bounce2" to import the library to your sketch. An "#include Bounce2.h" line will appear at the top of your Sketch.
Instantiates a Bounce object.
void interval(unsigned long interval)
Sets the debounce time in milliseconds.
void attach(int pin)
Sets the pin and matches the internal state to that of the pin. Only attach the pin once you have done setting the pin up (for example setting an internal pull-up).
Because Bounce does not use interrupts, you have to "update" the object before reading its value and it has to be done as often as possible (that means to include it in your loop()). The update() method updates the object and returns true (1) if the pin state changed. False (0) if not. Only call update() once per loop().
Reads the updated pin state.
Returns true if pin signal transitions from high to low.
Returns true if signal transitions from low to high.
Deprecated. An alias for rose(). For compatibility with Bounce 1.0.
Deprecated. An alias for fell(). For compatibility with Bounce 1.0.
Bounce(uint8_t pin, unsigned long interval_millis )
Deprecated. Creates an instance of the Bounce class, attaches pin and sets interval to interval_millis. For compatibility with Bounce 1.0.
By default, the Bounce library uses a stable interval to process the debouncing. This is simpler to understand and can cancel unwanted noise.
By defining "#define BOUNCE_LOCK_OUT" in "Bounce.h" you can activate the alternative debouncing method. This method is a lot more responsive, but does not cancel noise.