A class to handle a push button connected to the TKJHAT board. More...
#include <Button.h>
Public Member Functions | |
| void | begin () |
| Initialize the button pin. | |
| Button (uint8_t pin) | |
| Create a Button instance. | |
| bool | isPressed () |
| Read the button state. | |
A class to handle a push button connected to the TKJHAT board.
The JTKJ HAT exposes two user buttons connected to GPIO 2 and GPIO 22. They are configured as digital inputs using the board’s hardware pull-downs. Use gpio_get(SW1_PIN) or gpio_get(SW2_PIN) to poll their state.
Pins:
| Name | Macro | GPIO |
|---|---|---|
| SW1 | SW1_PIN / BUTTON1 | 2 |
| SW2 | SW2_PIN / BUTTON2 | 22 |
| Button::Button | ( | uint8_t | pin | ) |
Create a Button instance.
| pin | GPIO pin connected to the button, either 2 (SW1) or 22 (SW2) |
| void Button::begin | ( | ) |
Initialize the button pin.
Configures the pin mode. Must be called in setup().
| bool Button::isPressed | ( | ) |
Read the button state.