T edited this page Apr 20, 2018 · 16 revisions


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.


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).

bool update()

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().

bool read()

Reads the updated pin state.

bool fell()

Returns true if pin signal transitions from high to low.

bool rose()

Returns true if signal transitions from low to high.

bool risingEdge()

Deprecated. An alias for rose(). For compatibility with Bounce 1.0.

bool fallingEdge()

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.


Stable interval

By default, the Bounce library uses a stable interval to process the debouncing. This is simpler to understand and can cancel unwanted noise.

Lock-out interval

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.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.