Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
Button Class Reference

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.

Detailed Description

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
Note
Logic is active-high (pressed = 1, released = 0).

Constructor & Destructor Documentation

◆ Button()

Button::Button ( uint8_t pin)

Create a Button instance.

Parameters
pinGPIO pin connected to the button, either 2 (SW1) or 22 (SW2)

Member Function Documentation

◆ begin()

void Button::begin ( )

Initialize the button pin.

Configures the pin mode. Must be called in setup().

◆ isPressed()

bool Button::isPressed ( )

Read the button state.

Returns
true if the button is currently pressed, false otherwise

The documentation for this class was generated from the following file: