Files
zephyr/samples/basic/button/README.rst
Fabio Baltieri 68999e6fcf samples: button: rework to use the input and leds subsystem
Rework the button sample to use the input subsystem for the button and
LED subsystem for the LED. This is a better representation of how a
button and LED should be controlled in Zephyr.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-01-15 16:40:48 +00:00

36 lines
1.0 KiB
ReStructuredText

.. zephyr:code-sample:: button
:name: Button
:relevant-api: input_interface
Handle GPIO button inputs using the input subsystem.
Overview
********
A simple button demo showcasing the use of buttons with the :ref:`input` APIs.
The sample prints a message to the console each time a button is pressed.
Requirements
************
The board hardware must have a device node capable of generating input KEY
events, typically a push button connected via a GPIO pin and defined in a
"gpio-keys" node. These are called "User buttons" on many of Zephyr's
:ref:`boards`.
The sample additionally supports an optional ``led0`` devicetree alias. If this
is provided, the LED will be turned on when the button is pressed, and turned
off when it is released.
Building and Running
********************
This sample can be built for multiple boards, in this example we will build it
for the nucleo_f103rb board:
.. zephyr-app-commands::
:zephyr-app: samples/basic/button
:board: nucleo_f103rb
:goals: build
:compact: