The Button Example demonstrates the use of GPIO input with interrupts. The example prints a message to the console each time a button is pressed. An optional
led0 devicetree alias is supported additionally. The LED will be turned on when the button is pressed, and turned off when it is released.
Before you start building, the Zephyr development environment should be set up correctly:
Build the example¶
You can find the source code and the project file of the example in the following folder: examples/zephyr/button.
Build the example by performing the following steps:
Open terminal and navigate to the
m2devkitdirectory created in the Setup the toolchain section:
westto build the example:
west build -b nrf52840_m2 nrf52840-m2-devkit/examples/zephyr/button
If a build system is present, make the build folder pristine before building:
west build -t pristine
Flash the example¶
After compiled successfully, the firmware is located in
m2devkit/build/zephyr with the name
Connect the debugger USB port to your PC using the provided USB-C Cable. A disk drive called M2-DOCK will be automatically detected by the computer.
Run the following command to flash the board:
Test the Button Example application by performing the following steps:
screen /dev/cu.usbmodem14102 115200
Press the USER button, then observe the GREEN LED and the output of the terminal.
Create an Issue¶
Interested in contributing to this project? Want to report a bug? Feel free to click here: