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

The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named, but it will be kept that so it stays compatible with previous code. More...

#include <Bounce2.h>

Inheritance diagram for Bounce:
Debouncer Bounce2::Button

Public Member Functions

 Bounce ()
 Create an instance of the Bounce class. More...
 
void attach (int pin, int mode)
 Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT). More...
 
void attach (int pin)
 
 Bounce (uint8_t pin, unsigned long interval_millis)
 
int getPin () const
 Return pin that this Bounce is attached to. More...
 
bool risingEdge () const
 Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1.
 
bool fallingEdge () const
 Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1.
 
- Public Member Functions inherited from Debouncer
 Debouncer ()
 Create an instance of the Debounce class. More...
 
void interval (uint16_t interval_millis)
 Sets the debounce interval in milliseconds. More...
 
bool update ()
 Updates the pin's state. More...
 
bool read () const
 Returns the pin's state (HIGH or LOW). More...
 
bool fell () const
 Returns true if pin signal transitions from high to low.
 
bool rose () const
 Returns true if pin signal transitions from low to high.
 
bool changed () const
 Returns true if the state changed on last update. More...
 
unsigned long currentDuration () const
 Returns the duration in milliseconds of the current state. More...
 
unsigned long previousDuration () const
 Returns the duration in milliseconds of the previous state. More...
 
unsigned long duration ()
 DEPRECATED (i.e. do not use). Renamed currentDuration(). More...
 

Protected Member Functions

virtual bool readCurrentState ()
 
virtual void setPinMode (int pin, int mode)
 
- Protected Member Functions inherited from Debouncer
void begin ()
 

Protected Attributes

uint8_t pin
 Deprecated (i.e. do not use). Included for partial compatibility for programs written with Bounce version 1.
 
- Protected Attributes inherited from Debouncer
unsigned long previous_millis
 
uint16_t interval_millis
 
uint8_t state
 
unsigned long stateChangeLastTime
 
unsigned long durationOfPreviousState
 

Detailed Description

The Debouncer:Bounce class. Links the Deboucing class to a hardware pin. This class is odly named, but it will be kept that so it stays compatible with previous code.

Constructor & Destructor Documentation

◆ Bounce()

Bounce::Bounce ( )

Create an instance of the Bounce class.

// Create an instance of the Bounce class.
Bounce() button;

Member Function Documentation

◆ attach() [1/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).

◆ attach() [2/2]

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

Attach to a pin and sets that pin's mode (INPUT, INPUT_PULLUP or OUTPUT).

Parameters
pinThe pin that is to be debounced.
modeA valid Arduino pin mode (INPUT, INPUT_PULLUP or OUTPUT).

◆ getPin()

int Bounce::getPin ( ) const
inline

Return pin that this Bounce is attached to.

Returns
integer identifier of the coupled pin

The documentation for this class was generated from the following files:
Bounce::Bounce
Bounce()
Create an instance of the Bounce class.
Definition: Bounce2.cpp:138