Arduino UNO Q - Button Module
Think of a doorbell, a "start" key for a game, or a single key that sends a message to your phone. Each one begins with a press of a button. The button module makes that press easy to read: the resistor is already on the board, the pins have names, and a press gives a clean HIGH. On the Arduino UNO Q, the STM32 MCU watches the button, and the Linux side can turn each press into a Python event or a Telegram alert.
This page covers:
- What the button module is, and why it needs no extra resistor
- Why VCC must go to 3.3V on the Arduino UNO Q, not to 5V
- How to read the raw pin level from the MCU
- How to catch press and release events with a short delay debounce
- How to read the button without blocking, using the ezButton library
- How Python on Linux can ask the MCU for the button state and the number of presses through Bridge
- How to build a Telegram doorbell that alerts you on every press and answers /status and /count
- How to use OpenClaw on Arduino UNO Q with the button module

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
Three jumper wires are all you need — no breadboard and no resistor. OUT goes to pin 7, and VCC takes its power from the 3.3V header pin.

This image is created using Fritzing. Click to enlarge image
| Button Module Pin | Arduino UNO Q |
|---|---|
| VCC | 3.3V |
| OUT | Pin 7 |
| GND | GND |
If you plan to keep this circuit, think about screw terminals. To do that, mount a Proto Screw Terminal Block Shield or a Screw Shield V2 on the Arduino UNO Q. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
Any digital pin can read the module. If you choose another pin, change BUTTON_MODULE_PIN in every sketch on this page.
Arduino UNO Q Code
The UNO Q is two computers on one board:
- The STM32 MCU reads pin 7, so it is the part that "feels" each press
- The Qualcomm MPU runs Debian Linux, Python and Wi-Fi
- The three examples in this part run on the MCU only. The Linux side gets its turn in the Bridge section
Example 1 - Read the Raw State
The simplest possible test: read pin 7 four times per second and print the number. If you see 0 at rest and 1 while you hold the cap, your wiring is right.
Detailed Instructions
New to the Arduino UNO Q? Start with Getting Started with Arduino UNO Q to set up Arduino App Lab.
- Wire it up: VCC to 3.3V, OUT to pin 7, GND to GND, as in the diagram. Check VCC twice — it must be 3.3V.
- Plug in: Connect the Arduino UNO Q to your PC with the USB-C cable.
- Start Arduino App Lab and let it detect the board.
- Make a new App: Click Create New App.

- Call it ButtonModuleRawState, then click Create.

- Add the code: Open sketch/sketch.ino, replace its content with the sketch above, and leave the other files alone. This example uses no library.
- Run it: Press the Run button.

- Test it: Hold the cap down for a second, then let go, and watch the console.
App Lab Console Output
The value stays at 0 when nobody touches the button — it never floats, because of the pull-down. If it stays at 0 even when you press, check that OUT really goes to pin 7.
Example 2 - Press and Release Events (Delay Debounce)
Most projects do not care about the level itself. They care about the moment it changes: "the doorbell was just pressed". This sketch remembers the last confirmed state. When a new reading differs, it waits 50 ms, reads again, and only reports the change if it is still there — so bounce is ignored.
Detailed Instructions
- The wiring does not change.
- Make a new App called ButtonModuleDebounceDelay (or reuse the last one), put the code in sketch/sketch.ino, and click Run.
- Press the button three times, slowly. Each press should give exactly one "pressed" line and one "released" line.
App Lab Console Output
The weak point: delay() freezes the whole loop for those 50 ms, so nothing else in the sketch can run while it waits.
Example 3 - Non-Blocking Debounce with ezButton
The ezButton library does the same job without stopping the loop. It keeps a timer inside and only accepts a change after the pin has been steady for the debounce time. You get three handy calls:
- button.isPressed() — true once, right after a press
- button.isReleased() — true once, right after a release
- button.getState() — the clean, debounced level (HIGH = held down)
Remember to call button.loop() at the top of every loop(). It returns at once, so the rest of your sketch keeps running.
Detailed Instructions
- Make a new App named ButtonModuleEzButton and paste the code into sketch/sketch.ino.
- Add the library to the App:
- Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.

- Search for ezButton created by ArduinoGetStarted.com and click the Install button.
- Use ezButton version 1.0.6 or newer. Older versions do not have the EXTERNAL_PULLDOWN mode.
- Click Run. Tap the button a few times, then hold it down for about three seconds.
App Lab Console Output
The events appear the moment they happen, while the steady-state line keeps its own 2-second rhythm. That is the non-blocking style at work.
Bridge: Linux + MCU
A button is an input, so the data flows from the MCU to Linux. Python cannot touch pin 7 — it has to ask the MCU:
- The MCU owns the button. It runs ezButton on pin 7 and counts every clean press
- It shares three read-only values with Bridge.provide():
- get_button_state — pressed or released, right now
- get_press_count — the total number of presses since power-on
- take_new_presses — the presses since the last call. The MCU then sets this number back to 0
- Why take_new_presses? Python polls only every 0.2 seconds. A quick tap can start and end between two polls, so get_button_state alone could miss it. The counter on the MCU never misses one
- Python polls with Bridge.call() and prints an event line for each new press and each state change
- ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in your code
In short: you press → the MCU counts it → Python calls take_new_presses → Python prints the event.
MCU Code (Bridge)
Python Code (Bridge)
Detailed Instructions
- Create the App: In Arduino App Lab, click Create New App and name it ButtonModuleBridge.
- MCU side: Paste the MCU sketch into sketch/sketch.ino, then add both libraries:
- Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.

- Search for ezButton created by ArduinoGetStarted.com and click the Install button.
- Search for Arduino_RouterBridge created by Arduino and click the Install button.
- Linux side: Paste the Python code into the Python file of the same App.
- Run: Click the Run button.
- Try it: Press once and hold for a moment. Then tap it twice very fast.
- Read both consoles: The MCU Monitor shows each press as it happens. The Python console shows what Linux learned from its calls.
App Lab Console Output
Look at the last line: the two fast taps came between two polls, so Python never saw the state as PRESSED. Still, take_new_presses reported both of them.
Telegram
Now the button becomes a doorbell. Mount the module next to your front door, at your workbench, or by a sick person's bed. Every press sends a "Ding dong!" message to your phone, wherever you are. You can also ask the bot about the button at any time.
| Command | What it does |
|---|---|
| /start | turn on doorbell alerts for this chat |
| /stop | turn off doorbell alerts for this chat |
| /status | is someone holding the button right now? |
| /count | how many presses since power-on |
The bot sends alerts only to chats that sent /start, so you do not need to look up your chat ID. If several presses happen within one poll, they are joined into one message, so a fast finger does not flood your phone.
MCU sketch: Use the MCU sketch from the Bridge section without changes.
Python Code (Telegram)
Detailed Instructions
- Bot token: Make a bot with @BotFather and copy its token into TELEGRAM_BOT_TOKEN. Need help? See How to Create a Telegram Bot.
- Python file: In your ButtonModuleBridge App, replace the Python code with the bot script. The sketch stays as it is.
- Run: Click the Run button.
- Subscribe: Open your bot in Telegram and send /start.
- Ring it: Press the button module. The alert should arrive within a second or two.
- Note: The list of subscribed chats lives in memory. After you restart the App, send /start again.
App Lab Console Output
ArduinoBot
OpenClaw
You can adapt the OpenClaw to this tutorial by refering the instruction on Arduino Uno Q - OpenClaw Tutorial
Project Ideas
One button and a Linux computer can do a surprising amount:
- Smart Doorbell with Photo: Add a USB camera to the UNO Q. On each press, Python takes a picture and sends it with the Telegram alert.
- Quiz Buzzer: Give each player a module with a different cap color. The MCU decides who pressed first, and Python shows the winner's name.
- Meeting Timer Key: One press starts a 25-minute focus timer on the Linux side, a second press stops it and logs the time to a file.
- Help Call Button: An elderly relative presses the module and the whole family chat gets a message at once.
- Shortcut Key for Scripts: Each press runs a Python script — back up a folder, restart a service, or switch a smart plug.
Challenge Yourself
Try these on your own:
- Easy: In Example 3, count the presses and print the total each time the button is released.
- Medium: Add a long press to the Bridge sketch: when the button is held for more than 2 seconds, set a flag, and expose it to Python as get_long_press.
- Advanced: Make the Telegram bot quiet at night. Between 22:00 and 07:00, store the presses and send one summary message in the morning instead.
