button
button copied to clipboard
Pullup
Hi, sorry my programming skills are close to zero. I was wondering what would be the right way to setup the internal pullup resistors when using the library. thanks for helping
A bit late, so you probably found a solution of moved on, but here is my best attempt at explaning this anyway.
You don't need to set up the internal pullup resistors, ezButton does that for you by default.
If you look in the ezButton code in the file ezButton.cpp, you can see this on line 34
ezButton::ezButton(int pin): ezButton(pin, INPUT_PULLUP) {};
This means the constructor ezButton(int pin) will call the second constructor ezButton(pin, INPUT_PULLUP).
What this means is when you e.g. put this in your code:
#define MY_BUTTON_PIN 3
ezButton myButton(MY_BUTTON_PIN)
The ezButton library will create a new instance of the ezButton class with this constructor: ezButton(3, INPUT_PULLUP).
We just released new version 1.0.5 that supports internal pull-up/pull-down, external pull-up/pull-down.
Note:
- Some Arduino boards do not support
INTERNAL_PULLDOWN
- ESP32 board: Pins GPIO34, GPIO35, GPIO36(VP) and GPIO39(VN) does not support
INTERNAL_PULLDOWN
andINTERNAL_PULLUP
. - It is good to read boards manual to check if a pin support
INTERNAL_PULLDOWN
andINTERNAL_PULLUP
.