https://github.com/lpg2709/btnsdebouncing
btnSDebouncing.h is a header only lib that implements simple software debouncing for push buttons.
https://github.com/lpg2709/btnsdebouncing
arduino c cpp esp32 esp32-arduino lib
Last synced: 9 months ago
JSON representation
btnSDebouncing.h is a header only lib that implements simple software debouncing for push buttons.
- Host: GitHub
- URL: https://github.com/lpg2709/btnsdebouncing
- Owner: lpg2709
- License: mit
- Created: 2020-09-16T20:53:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-16T21:03:26.000Z (over 5 years ago)
- Last Synced: 2025-04-02T04:55:38.344Z (9 months ago)
- Topics: arduino, c, cpp, esp32, esp32-arduino, lib
- Language: C
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# btnSDebouncing.h
btnSDebouncing.h is a header only lib that implements simple software debouncing for push buttons.
## How use:
In your file where a button will be used:
```c
#define BTNSDEBOUCINH_H
#include "btnSDebouncing.h"
```
## What's in the lib
A button data type and a function to read the button.
### Button: type[struct]
Structure containing button data, where:
- int pin: The board pin where the button is connected
- int state: The state of the button, ```HIGH``` or ```LOW```
- int lastState: The last state of the button, ```HIGH``` or ```LOW```
- unsigned long lastDebounceTime: The last time of the boucing, initialize with ```0```;
### readDButton: type[function]
Function that performs button reading without bouncing
```c
/*! @brief button reading without bouncing
* @param [Button] *btn - The adress of the button data
* @param [unsigned long] debounceDelay - The delay of the boucing, if pass NULL the default is 50 ms
* @return bool
*/
bool readDButton(Button *btn, unsigned long debounceDelay);
```
if the button is presses, return ```true```