Arduino UNO Q - Button - LED
This tutorial shows how to use a button to control an LED with Arduino UNO Q. Two applications are covered:
Application 1 — LED follows button state:
- LED turns ON when the button is pressed
- LED turns OFF when the button is released
Application 2 — LED toggles on each press:
- Each button press flips the LED between ON and OFF
- Releasing the button does not change the LED state
- Includes debounce-free and debounced versions (using ezButton)

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Buy Note: Use the LED Module for easier wiring. It includes an integrated resistor.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Linux + MCU Bridge Programming
The Arduino UNO Q has two processors that work together: the MPU (Qualcomm, runs Debian Linux) and the MCU (STM32, runs Zephyr OS with your Arduino sketch). They communicate using RPC via the Arduino_RouterBridge library — never via raw serial ports.
- The button and LED are connected to the MCU (STM32) — the button is wired to a digital input pin and the LED to a digital output pin on the STM32. The MCU handles the toggle logic and debounce using ezButton.
- The MPU cannot read the button or control the LED directly — it must request the LED state from the MCU via Bridge.call().
- The MPU has Wi-Fi — because the MPU runs full Debian Linux with Wi-Fi, it can report the LED state via Telegram on demand.
- Communication: Bridge.call() on the Linux side invokes Bridge.provide() functions on the MCU side
- ⚠️ Reserved: /dev/ttyHS1 (Linux) and Serial1 (MCU) are used by the Arduino Router — never open them directly
In short: MPU requests LED state → MCU reads current state → MCU reports ON or OFF → MPU logs or forwards it.
MCU sketch — button-LED toggle with Bridge and Monitor output:
Python script (Arduino App Lab) — poll LED state from Linux:
- Note: Make sure Bridge.begin() is called in the MCU sketch and the sketch is uploaded before running the Python script on the Linux side.
- ⚠️ Warning: Never directly open /dev/ttyHS1 (on Linux) or use Serial1 (on MCU) in your code — these are reserved by the Arduino Router and accessing them will break the Bridge.
Detailed Instructions
- Upload the MCU sketch: Open Arduino App Lab, create a new App, paste the Bridge MCU sketch above into sketch/sketch.ino, install the ezButton and Arduino_RouterBridge libraries, and click Run.
- Add the Python script: Paste the Python code above into the Python tab of the same App.
- Run the App: Click Run — the Python side polls the LED state every 3 seconds.
- Press the button multiple times to toggle the LED.
- Check the console: Open the Console tab → MCU Monitor subtab to see toggle events logged in real time.
App Lab Console Output
Telegram Integration
Check the current LED state remotely from anywhere via Telegram.
If you do not have a Telegram bot yet, see How to Create a Telegram Bot to get your bot token before continuing.
MCU sketch: Keep the same MCU sketch from the previous Bridge section — no changes needed. Make sure it is already uploaded and running on the STM32 before proceeding.
Python script (Arduino App Lab) — Telegram bot for LED state:
- Note: Replace YOUR_BOT_TOKEN with the token obtained from @BotFather on Telegram.
- Send /state to check whether the LED is currently ON or OFF.
Detailed Instructions
- Upload the MCU sketch: Use the Bridge MCU sketch from the previous section (upload it first if not already done).
- Paste the Telegram script: Copy the Python code above into the Python tab of your App in Arduino App Lab.
- Set your token: Replace YOUR_BOT_TOKEN in the script with your actual bot token.
- Run the App: Click Run — the bot starts listening for Telegram messages.
- Test it: Press the button to toggle the LED, then send /state — confirm the state matches.
App Lab Console Output
ArduinoBot
OpenClaw Integration
OpenClaw integration for Arduino UNO Q button-LED control is coming soon.
- Coming Soon: OpenClaw support for button-LED interaction on Arduino UNO Q will be covered in a future update.
Application/Project Ideas
- Telegram LED monitor: Press a physical button to toggle a lamp and check its state remotely via Telegram
- Physical alarm toggle: Use a button to arm/disarm an alarm and confirm state from anywhere
- Presentation controller: Toggle a display or notification light with a button while checking state remotely
- Night mode switch: Press a button to toggle night mode on devices; monitor via Telegram
- Access confirmation: Press a button to confirm entry; check LED/gate state via Telegram
Challenge Yourself
- Easy: Add a second LED that turns OFF when the first LED turns ON (alternating LEDs)
- Medium: Extend the Bridge sketch to count total button presses and expose the count as get_press_count()
- Advanced: Build a Telegram bot that automatically sends a notification each time the LED state changes — use a monitoring loop in Python that polls state and compares to previous value



