Arduino UNO Q - Button
The push button is one of the most fundamental components in Arduino projects. This tutorial teaches you everything you need to use a button correctly with Arduino UNO Q — from reading its state to detecting press and release events, and even checking the button state remotely via Telegram.
※ NOTE THAT:
Before we begin, here are two common beginner mistakes to watch out for:
- Floating input problem:
- Symptom: The button pin reads unpredictable values even when the button is not pressed.
- Cause: No pull-up or pull-down resistor is connected.
- Solution: Use INPUT_PULLUP mode in Arduino code — this enables the internal pull-up resistor and requires no external component.
- Chattering phenomenon:
- Symptom: One physical press registers as multiple press events.
- Cause: Mechanical bouncing causes rapid HIGH/LOW transitions.
- Solution: Implement debounce. See the Arduino UNO Q - Button Debounce tutorial.
Chattering only affects applications that need a precise count of presses. For simple ON/OFF control, it usually does not matter.

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 .
Wiring Diagram
- Wiring for PCB-mount button:

This image is created using Fritzing. Click to enlarge image
- Wiring for panel-mount button:

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 is connected to the MCU (STM32) — wired to a digital input pin on the STM32. The MCU reads the button state using digitalRead().
- The MPU cannot read the button directly — it must request the current state from the MCU via Bridge.call(). The MCU executes the registered Bridge.provide() function and responds.
- The MPU has Wi-Fi — because the MPU runs full Debian Linux with Wi-Fi, it can check the button state on demand and forward it via Telegram.
- 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 button state → MCU reads pin → MCU reports result → MPU logs or forwards it.
MCU sketch — button with Bridge and Monitor output:
Python script (Arduino App Lab) — poll button 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, keep the default 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 button state every 0.5 seconds.
- Press the button: Press and hold it, then release it.
- Check the console: Open the Console tab → MCU Monitor subtab to see press/release events in real time.
- Pro Tip: Also open the Python Console subtab to see the polled state values.
App Lab Console Output
Telegram Integration
You can check whether the button is currently pressed — from anywhere in the world — by sending a Telegram message to your Arduino UNO Q.
If you do not have a Telegram bot yet, see How to Create a Telegram Bot to get your bot token before continuing.
This section covers:
- Running a Python script on the Linux side of Arduino UNO Q to listen for Telegram messages
- Polling the button state from the MCU via Bridge.call() on demand
- Sending the button state back to Telegram as a reply
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 button state:
- Note: Replace YOUR_BOT_TOKEN with the token obtained from @BotFather on Telegram.
- Send /state to check whether the button is currently pressed.
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 immediately.
- Test it: Open Telegram, find your bot, press the physical button on Arduino UNO Q, and then send /state to see if it reads as pressed.
- Pro Tip: Combine with an LED — light it up when the button is detected as pressed via Bridge.
App Lab Console Output
ArduinoBot
OpenClaw Integration
You can adapt the OpenClaw to this tutorial by refering the instruction on Arduino Uno Q - OpenClaw Tutorial
Application/Project Ideas
Here are some project ideas using a button with Arduino UNO Q:
- Remote doorbell: Press the button → Telegram sends "Someone is at the door!" to your phone
- Emergency alert: Press and hold for 3 seconds → Telegram sends an alert message
- Event counter: Count button presses on the MCU and send the total via Telegram on demand
- Light switch: Press button → turn on a connected light; press again → turn it off
- Two-mode system: Short press selects mode A, long press selects mode B — each triggers a different Python action
Challenge Yourself
Try these challenges with buttons on Arduino UNO Q:
- Easy: Modify the Bridge sketch to turn on the built-in LED when the button is pressed and turn it off when released
- Medium: Extend the Bridge sketch to expose a get_press_count() function that returns how many times the button has been pressed since power-on
- Advanced: Build a Telegram bot that sends a message automatically (without polling) whenever the button is pressed — use a background loop in Python to monitor state changes via Bridge








