Bounce2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Bounce Class Reference

#include <Bounce2.h>

Public Member Functions

 Bounce ()
 
void attach (int pin, int mode)
 
void attach (int pin)
 
void interval (uint16_t interval_millis)
 
bool update ()
 
bool read ()
 
bool fell ()
 
bool rose ()
 
bool risingEdge ()
 
bool fallingEdge ()
 
 Bounce (uint8_t pin, unsigned long interval_millis)
 
unsigned long duration ()
 

Protected Member Functions

virtual bool readCurrentState ()
 
virtual void setPinMode (int pin, int mode)
 

Protected Attributes

unsigned long previous_millis
 
uint16_t interval_millis
 
uint8_t state
 
uint8_t pin
 
unsigned long stateChangeLastTime
 

Detailed Description

The Bounce class.

Constructor & Destructor Documentation

◆ Bounce()

Bounce::Bounce ( )

Create an instance of the Bounce class.

Member Function Documentation

◆ attach() [1/2]

void Bounce::attach ( int  pin,
int  mode 
)

Attach to a pin and sets that pin's mode (INPUT/INPUT_PULLUP/OUTPUT)

◆ attach() [2/2]

void Bounce::attach ( int  pin)

Attach to a pin for advanced users. Only attach the pin this way once you have previously set it up. Otherwise use attach(int pin, int mode).

◆ duration()

unsigned long Bounce::duration ( )

Returns the duration in milliseconds of the current state. Is reset to 0 once the pin rises or falls.

◆ fell()

bool Bounce::fell ( )

Returns true if pin signal transitions from high to low.

◆ interval()

void Bounce::interval ( uint16_t  interval_millis)

Sets the debounce interval in milliseconds.

◆ read()

bool Bounce::read ( )

Returns the pin's state (HIGH or LOW).

◆ rose()

bool Bounce::rose ( )

Returns true if pin signal transitions from low to high.

◆ update()

bool Bounce::update ( )

Updates the pin's state. Returns 1 if the state changed. Returns 0 if the state did not change. 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()). Only call update() once per loop().


The documentation for this class was generated from the following files: