Skip to content

bdubs-astro/DebounceSwitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

DebounceSwitch

A c class for de-bouncing a mechanical switch.

The parameters are the GPIO pin #, a flag that's true if using an internal pullup resistor, a pair of callback functions that get called when the pin goes either high or low, and a debounce delay in ms.

▪️ The initPin() function must be called first. It configures the input pin, and returns the inital state of the switch.

▪️ The readPin(int debounceDelay) function returns the current state (de-bounced), and calls the corresponding callback function whenever the state changes.

Digital Inputs: Pullup vs. Pulldown Resistors

ESP8266 D1 Mini Pinout

Source: https://www.mischianti.org/2021/04/26/wemos-d1-mini-high-resolution-pinout-and-specs/

Source: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

ESP32 Dev Kit Pinout

Source: https://forum.fritzing.org/t/esp32s-hiletgo-dev-boad-with-pinout-template/5357