Arduino UNO Q - Keypad - LCD

Want to type on a keypad and see the characters appear on an LCD display with your Arduino UNO Q? In this tutorial, you will learn exactly that — plus how to monitor and clear the display remotely via Telegram.

In this tutorial, you will learn:

Arduino UNO Q Keypad LCD

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×LCD I2C 16x2
1×Alternatively, LCD I2C 20x4
1×Keypad 3x4
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno
1×Recommended: Sensors/Servo Expansion Shield for Arduino Uno
1×Recommended: Breadboard Shield for Arduino Uno
1×Recommended: Enclosure for Arduino Uno
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Buy Note: Alternatively, you can assemble the LCD I2C display using LCD 1602 Display and PCF8574 I2C Adapter Module.

Overview of the Keypad and LCD

If you are new to the 3x4 keypad or I2C LCD display, check these tutorials first:

Wiring Diagram

The wiring diagram between Arduino UNO Q Keypad LCD

This image is created using Fritzing. Click to enlarge image

Keypad 3x4 connections:

Keypad Pin Arduino UNO Q MCU
R1 (Row 1) D9
R2 (Row 2) D8
R3 (Row 3) D7
R4 (Row 4) D6
C1 (Col 1) D5
C2 (Col 2) D4
C3 (Col 3) D3

LCD I2C connections:

LCD I2C Pin Arduino UNO Q MCU
VCC 5V
GND GND
SDA A4
SCL A5

Arduino UNO Q Code

The Arduino UNO Q has two processors working together:

  • The STM32 MCU reads the keypad and drives the LCD directly — all display and input logic runs on the MCU
  • 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.

Pressing a key displays it on the LCD. Pressing * clears the screen.

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd #include <DIYables_Keypad.h> #include <DIYables_LCD_I2C.h> const int ROW_NUM = 4; const int COLUMN_NUM = 3; char keys[ROW_NUM][COLUMN_NUM] = { { '1', '2', '3' }, { '4', '5', '6' }, { '7', '8', '9' }, { '*', '0', '#' } }; byte pin_rows[ROW_NUM] = { 9, 8, 7, 6 }; byte pin_column[COLUMN_NUM] = { 5, 4, 3 }; DIYables_Keypad keypad = DIYables_Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM); DIYables_LCD_I2C lcd(0x27, 16, 2); int cursorColumn = 0; void setup() { Serial.begin(115200); delay(1500); lcd.init(); lcd.backlight(); lcd.print("Keypad LCD Ready"); Serial.println("Arduino UNO Q Keypad + LCD ready"); } void loop() { char key = keypad.getKey(); if (key) { Serial.print("Key pressed: "); Serial.println(key); if (key == '*') { // Clear LCD lcd.clear(); cursorColumn = 0; } else { lcd.setCursor(cursorColumn, 0); lcd.print(key); cursorColumn++; if (cursorColumn == 16) { lcd.clear(); cursorColumn = 0; } } } }

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 3x4 keypad and LCD I2C 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.
  • Create a new App: Click the Create New App button.
Create New App in Arduino App Lab on Arduino UNO Q
  • Give the App a name, for example: KeypadLcd
  • Click Create to confirm.
Arduino App Lab App folders and files on Arduino UNO Q
  • Paste the sketch: Copy the MCU code above and paste it into sketch/sketch.ino. Keep other files as default.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
Add sketch library in Arduino App Lab on Arduino UNO Q
  • Search for DIYables_Keypad created by DIYables.io and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
DIYables_Keypad DIYables.io

The library is designed for Arduino, ESP32, ESP8266... to use with keypad such as 3x4, 4x4 keypad. It also works with Arduino Uno R4 WiFi/Minima

1.0.1
Install
More Info
  • Search for DIYables LCD I2C created by DIYables.io and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
DIYables LCD I2C DIYables.io

This library is designed for HD44780-based I2C LCD displays. It provides LiquidCrystal-compatible API plus helper functions (text alignment, progress bars, predefined custom characters). Supports multiple I2C buses (Wire, Wire1, Wire2) for advanced boards like Arduino Giga, Due, and ESP32. Compatible with all Arduino-based platforms including Arduino Uno, Mega, Nano, ESP32, ESP8266, STM32, and Raspberry Pi Pico.

1.0.0
Install
More Info
  • Upload: Click the Run button in Arduino App Lab.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Press keys on the keypad — each character appears on the LCD. Press * to clear.

※ NOTE THAT:

If the LCD shows nothing, check Troubleshooting for LCD I2C for help.

Bridge: Linux + MCU

This section shows how to program both processors of the Arduino UNO Q so the Linux side can monitor keypad input and clear the LCD remotely:

  • The 3x4 keypad and LCD are connected to the MCU (STM32) — the MCU handles all key detection and display rendering
  • The MPU cannot access the keypad or LCD directly — it must call Bridge functions to read input and control the display
  • The MPU has Wi-Fi — running full Debian Linux, it can react to confirmed entries 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 reads keypad input and shows it on LCD → MPU monitors typing and confirmed entries via Bridge → MPU can react and notify from anywhere over the Internet.

Note: In the Bridge sketch, keypad.getKey() is called inside the Arduino loop() to continuously detect key presses — this is required and does not interfere with Bridge communication.

MCU Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd #include <DIYables_Keypad.h> #include <DIYables_LCD_I2C.h> #include "Arduino_RouterBridge.h" const int ROW_NUM = 4; const int COLUMN_NUM = 3; char keys[ROW_NUM][COLUMN_NUM] = { { '1', '2', '3' }, { '4', '5', '6' }, { '7', '8', '9' }, { '*', '0', '#' } }; byte pin_rows[ROW_NUM] = { 9, 8, 7, 6 }; byte pin_column[COLUMN_NUM] = { 5, 4, 3 }; DIYables_Keypad keypad = DIYables_Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM); DIYables_LCD_I2C lcd(0x27, 16, 2); String typed_buffer = ""; int cursorColumn = 0; bool entry_confirmed = false; String get_typed(String arg) { return typed_buffer; } String clear_lcd(String arg) { lcd.clear(); typed_buffer = ""; cursorColumn = 0; entry_confirmed = false; Monitor.println("LCD cleared"); return "OK"; } String get_status(String arg) { if (typed_buffer.length() == 0) return "LCD: empty"; if (entry_confirmed) return "Confirmed: " + typed_buffer; return "Typing: " + typed_buffer; } void setup() { Bridge.begin(); Monitor.begin(); lcd.init(); lcd.backlight(); lcd.print("Ready"); Bridge.provide("get_typed", get_typed); Bridge.provide_safe("clear_lcd", clear_lcd); Bridge.provide("get_status", get_status); Monitor.println("Arduino UNO Q Keypad + LCD Bridge ready"); } void loop() { char key = keypad.getKey(); if (key) { Monitor.println("Key pressed: " + String(key)); if (key == '*') { lcd.clear(); typed_buffer = ""; cursorColumn = 0; entry_confirmed = false; } else if (key == '#') { entry_confirmed = true; Monitor.println("Entry confirmed: " + typed_buffer); } else { lcd.setCursor(cursorColumn, 0); lcd.print(key); typed_buffer += key; cursorColumn++; if (cursorColumn == 16) { lcd.clear(); cursorColumn = 0; } } } }

Python Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd from arduino.app_utils import * import time def loop(): result = Bridge.call("get_status") print(result) if result.startswith("Confirmed:"): print(f"Entry confirmed — clearing in 3 seconds...") time.sleep(3) result = Bridge.call("clear_lcd") print(result) time.sleep(0.5) App.run(user_loop=loop)

Detailed Instructions

  • Connect: Wire the 3x4 keypad and LCD I2C 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 KeypadLcdBridge, 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.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Type on the keypad and press # to confirm — watch the Python console react.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Keypad + LCD Bridge ready [2026-04-29 09:00:05] Key pressed: 1 [2026-04-29 09:00:06] Key pressed: 2 [2026-04-29 09:00:07] Key pressed: 3 [2026-04-29 09:00:08] Key pressed: # [2026-04-29 09:00:08] Entry confirmed: 123
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:00:03] LCD: empty [2026-04-29 09:00:05] Typing: 1 [2026-04-29 09:00:06] Typing: 12 [2026-04-29 09:00:07] Typing: 123 [2026-04-29 09:00:08] Confirmed: 123 [2026-04-29 09:00:08] Entry confirmed — clearing in 3 seconds... [2026-04-29 09:00:11] OK

Telegram

Get Telegram notifications when a keypad entry is confirmed (# pressed) and remotely clear the LCD from your phone.

MCU sketch: Keep the same MCU sketch from the previous Bridge section.

Python Code (Telegram)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-keypad-lcd from arduino.app_utils import * import requests import time TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" last_update_id = 0 last_confirmed = "" def get_updates(): global last_update_id url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates" params = {"offset": last_update_id + 1, "timeout": 5} try: response = requests.get(url, params=params, timeout=10) data = response.json() if data["ok"]: return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": text} try: requests.post(url, data=payload, timeout=10) except Exception as e: print(f"Error sending message: {e}") def loop(): global last_update_id, last_confirmed # Auto-notify Telegram when # is pressed (entry confirmed) status = Bridge.call("get_status") if status.startswith("Confirmed:") and status != last_confirmed: last_confirmed = status msg = f"Keypad entry confirmed: {status[len('Confirmed: '):]}" print(msg) send_message(CHAT_ID, msg) # Handle incoming Telegram commands updates = get_updates() for update in updates: last_update_id = update["update_id"] if "message" not in update: continue message = update["message"] chat_id = message["chat"]["id"] text = message.get("text", "").strip() print(f"Received: {text}") if text == "/start": send_message(chat_id, "Arduino UNO Q Keypad + LCD Bot\n" "/typed - Get what's currently typed on the keypad\n" "/clear - Clear the LCD display\n" "/status - Get display status") elif text == "/typed": result = Bridge.call("get_typed") if result: send_message(chat_id, f"Typed: {result}") else: send_message(chat_id, "Nothing typed yet") elif text == "/clear": result = Bridge.call("clear_lcd") last_confirmed = "" send_message(chat_id, result) elif text == "/status": result = Bridge.call("get_status") send_message(chat_id, result) else: send_message(chat_id, "Unknown command. Send /start for help.") time.sleep(0.3) App.run(user_loop=loop)

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. Type on the keypad and press # — your Telegram chat receives a notification.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:15:00] Waiting for Telegram messages... [2026-04-29 09:15:10] Keypad entry confirmed: 1234 [2026-04-29 09:15:25] Received: /typed [2026-04-29 09:15:40] Received: /clear
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
/typed
10:15 AM ✓✓
Typed: 1234
10:16 AM
(presses # on keypad)
10:17 AM ✓✓
Keypad entry confirmed: 1234
10:18 AM
/clear
10:19 AM ✓✓
OK
10:20 AM
/status
10:21 AM ✓✓
LCD: empty
10:22 AM

OpenClaw

...OPENCLAW

OpenClaw support for Arduino UNO Q Keypad and LCD is coming soon.

...OPENCLAW

Project Ideas

You can build many creative projects combining the keypad and LCD with Arduino UNO Q:

  • Remote PIN Code Display: User types a PIN on the keypad and it appears on the LCD — the MPU receives a Telegram alert with the entered PIN when # is pressed
  • Smart Entry Logger: All confirmed keypad entries are logged with timestamps on the Linux MPU and forwarded to Telegram for remote monitoring
  • Display Message Board: The Python side sends a text string via Bridge and the MCU displays it on the LCD, while the keypad can be used to cycle through messages
  • Access Code Validator: Python validates the confirmed keypad entry against a list of authorized codes and sends "Access granted" or "denied" via Telegram
  • Multi-Step Input UI: Use the LCD to guide the user through a multi-step input sequence (e.g., first enter a code, then enter a value) — Python tracks the step state

Challenge Yourself

Ready to go further with the keypad and LCD on Arduino UNO Q? Try these challenges:

  • Easy: Modify the MCU sketch to show "CORRECT" or "WRONG" on the second LCD row when # is pressed, depending on whether the typed input matches a fixed password.
  • Medium: Add a display_message(String) Bridge function that clears the LCD and displays a custom message sent from Python — allowing the Linux MPU to write anything to the screen remotely.
  • Advanced: Build a full Telegram-controlled access panel: users type a PIN on the keypad, the MPU validates it via Bridge, sends a Telegram result, and if correct, activates a relay. Log all attempts with timestamps on the Linux side.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!