Arduino UNO Q - Keypad 1x4
Want to add a simple 4-button keypad to your Arduino UNO Q project? In this tutorial, you will learn how to detect key presses with debouncing — and even send Telegram alerts when a key is pressed.
In this tutorial, you will learn:
- What a 1x4 keypad is and how it works
- How to wire the 1x4 keypad to Arduino UNO Q
- How to program the MCU (C/C++ Arduino code) to detect key presses with debouncing
- How to program both the Linux side (Python) and MCU side (C/C++) to read the keypad via Bridge
- How to send Telegram notifications when a key is pressed on Arduino UNO Q
- How to use OpenClaw on Arduino UNO Q with the 1x4 keypad

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 .
Overview of the 1x4 Keypad
A 1x4 keypad has four buttons arranged in a single row. It is used for entering codes, navigating menus, or triggering actions in different projects.
Pinout
The 1x4 keypad has 5 pins. The pin order does not match the key order on the label:
- Pin 1 → Key 2
- Pin 2 → Key 1
- Pin 3 → Key 4
- Pin 4 → Key 3
- Pin 5 → Common (GND)

Wiring Diagram

This image is created using Fritzing. Click to enlarge image
| Keypad Pin | Arduino UNO Q MCU |
|---|---|
| Pin 1 (Key 2) | D2 |
| Pin 2 (Key 1) | D3 |
| Pin 3 (Key 4) | D4 |
| Pin 4 (Key 3) | D5 |
| Pin 5 (Common) | GND |
Arduino UNO Q Code
The Arduino UNO Q has two processors working together:
- The STM32 MCU reads the keypad pins directly with debouncing via the ezButton library
- The Qualcomm MPU runs Debian Linux and handles Wi-Fi, Python, and cloud connectivity
- In this section, only the MCU is programmed — the Linux side stays idle. A later section shows how both processors work together via Bridge.
Each key on the 1x4 keypad works like a button connected between a pin and GND. The ezButton library handles debouncing for all four keys automatically.
Detailed Instructions
First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial to get your development environment ready before proceeding.
- Connect: Wire the 1x4 keypad to the Arduino UNO Q MCU as shown in the wiring diagram above.
- Open Arduino App Lab: Launch Arduino App Lab and wait until it detects your Arduino UNO Q — this can take several minutes on first launch.
- Create a new App: Click the Create New App button.

- Give the App a name, for example: Keypad1x4
- Click Create to confirm.

- Find the sketch/sketch.ino file — this is where you will paste the MCU sketch.
- 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.
- Upload: Click the Run button in Arduino App Lab to compile and upload to the STM32.

- Open the Serial Monitor and press each key on the keypad. You will see the key number printed.
Bridge: Linux + MCU
This section shows how to program both processors of the Arduino UNO Q so the Linux side can read keypad presses remotely:
- The 1x4 keypad is connected to the MCU (STM32) — the MCU polls each key with debouncing in loop()
- The MPU cannot read keypad pins directly — it must request the last pressed key from the MCU via Bridge.call()
- The MPU has Wi-Fi — running full Debian Linux, it can react to key presses and send alerts over the Internet
- Arduino_RouterBridge enables RPC communication between the two processors
- ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in user code
In short: MCU polls the keypad → MPU reads the last key via Bridge → MPU can react to key presses from anywhere over the Internet.
Note: In the Bridge sketch, the ezButton polling loop is placed inside the Arduino loop() function to keep button state up to date — this is required and does not interfere with Bridge communication.
MCU Code (Bridge)
Python Code (Bridge)
Detailed Instructions
- Connect: Wire the 1x4 keypad to the Arduino UNO Q as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait for the board to be detected.
- Create a new App: Click Create New App, name it Keypad1x4Bridge, then click Create.
- Paste the MCU sketch: Copy the MCU Bridge code above and paste it into sketch/sketch.ino.
- Paste the Python code: Copy the Python Bridge code above and paste it into the Python file in the App.
- Upload: Click the Run button in Arduino App Lab.

- Press keys on the keypad and watch the Python console.
App Lab Console Output
Telegram
Get Telegram notifications when a key is pressed on the 1x4 keypad — useful for remote doorbells, access codes, or event triggers.
MCU sketch: Keep the same MCU sketch from the previous Bridge section.
Python Code (Telegram)
Detailed Instructions
- Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from BotFather.
- Replace YOUR_CHAT_ID with your Telegram chat ID.
- Paste this Python code into your App's Python file (keep the same MCU sketch).
- Click the Run button. Press keys on the keypad — your Telegram chat will receive alerts automatically.
App Lab Console Output
ArduinoBot
OpenClaw
...OPENCLAW
OpenClaw support for Arduino UNO Q Keypad 1x4 is coming soon.
...OPENCLAW
Project Ideas
You can build many creative projects using the 1x4 keypad with Arduino UNO Q:
- Remote Access Code Entry: User presses a 4-key combination on the keypad; the MPU receives the sequence via Bridge and validates it, then sends a Telegram alert on success or failure
- Menu Navigation System: Use keys 1–4 to navigate a menu on the Serial Monitor or LCD display — MPU tracks the selection and takes action
- Event Buzzer System: Each key on the keypad triggers a different action (e.g., turn on a relay, sound a buzzer, or send a Telegram notification)
- Simple Game Controller: Use the 1x4 keypad as directional input (left/right/up/down) in a simple text-based game running on the Linux MPU
- Telegram Doorbell: Press key 1 on the keypad to ring a Telegram "doorbell" — the MPU sends a notification to the homeowner's phone automatically
Challenge Yourself
Ready to go further with the 1x4 keypad on Arduino UNO Q? Try these challenges:
- Easy: Modify the MCU sketch to light up an LED connected to D6 whenever any key is pressed.
- Medium: Implement a 4-digit PIN code system on the MCU — pressing keys 1-2-3-4 in sequence unlocks a relay, while any wrong sequence resets the input.
- Advanced: Build a Telegram-based remote keypad: use /key to query the last pressed key, then build a state machine in Python that interprets key sequences as commands (e.g., 1-1-2 = "lights on", 2-1-1 = "lights off").