Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created August 12, 2025 15:29
Show Gist options
  • Save hidsh/25b0e95c86b81a7cdf1cdc340cab15ed to your computer and use it in GitHub Desktop.
Save hidsh/25b0e95c86b81a7cdf1cdc340cab15ed to your computer and use it in GitHub Desktop.
zephyr button example for xiao_ble (seeed xiao nrf52840)
// zephyr/samples/basic/button/boards/xiao_ble.overlay
//
// adopt from zephyr/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts
/{
buttons {
compatible = "gpio-keys";
button0: button_0 {
label = "Push button switch 0";
gpios = <&gpio0 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
zephyr,code = <INPUT_KEY_0>;
};
};
aliases {
sw0 = &button0;
};
};
@hidsh
Copy link
Author

hidsh commented Aug 12, 2025

❯❯ cd zephyr/samples/basic/button
❯❯ west build -p -b xiao_ble . && cp build/zephyr/zephyr.uf2 /media/XIAO-SENSE/CURRENT.UF2
❯❯ tio /dev/ttyACM0
[13:41:28.649] tio c43d2f6
[13:41:28.649] Press ctrl-t q to quit
[13:41:28.649] Connected to /dev/ttyACM0
*** Booting Zephyr OS build v4.2.0-1441-gbfd2ac78ad50 ***
Set up button at gpio@50000000 pin 4
Set up LED at gpio@50000000 pin 26
Press the button
Button pressed at 11458552
Button pressed at 11463122
Button pressed at 11463128
Button pressed at 11486589
Button pressed at 11501835

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment