아두이노 우노 Q 키패드와 LCD

Arduino UNO Q에서 키패드에 타이프한 문자가 LCD 디스플레이에 나타나는 것을 보고 싶으신가요? 이 튜토리얼에서는 정확히 그것을 배우게 됩니다 — 또한 Telegram을 통해 원격으로 디스플레이를 모니터링하고 지우는 방법도 배웁니다.

이 튜토리얼에서 배울 내용:

Arduino UNO Q 키패드 lcd

필요한 하드웨어

1×Arduino UNO Q 아마존
1×USB Cable for Arduino Uno Q 아마존
1×LCD I2C 16x2 쿠팡 | 아마존
1×(또는) LCD I2C 20x4 쿠팡 | 아마존
1×키패드 3x4 쿠팡 | 아마존
1×브레드보드 쿠팡 | 아마존
1×점퍼케이블 쿠팡 | 아마존
1×(추천) 아두이노 우노용 스크루 터미널 블록 쉴드 쿠팡 | 아마존
1×(추천) Sensors/Servo Expansion Shield for Arduino Uno 쿠팡 | 아마존
1×(추천) 아두이노 우노용 브레드보드 쉴드 쿠팡 | 아마존
1×(추천) 아두이노 우노용 케이스 쿠팡 | 아마존
1×(추천) 아두이노 우노용 프로토타이핑 베이스 플레이트 & 브레드보드 키트 아마존
공개: 이 포스팅 에 제공된 일부 링크는 아마존 제휴 링크입니다. 이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

키패드 및 LCD 소개

3x4 키패드 또는 I2C LCD 디스플레이를 처음 사용하시는 경우, 먼저 이 튜토리얼을 확인하세요:

배선도

Arduino UNO Q 키패드 lcd 배선도

이 이미지는 Fritzing을 사용하여 만들어졌습니다. 이미지를 확대하려면 클릭하세요.

키패드 3x4 연결:

키패드 핀 Arduino UNO Q MCU
R1 (행 1) D9
R2 (행 2) D8
R3 (행 3) D7
R4 (행 4) D6
C1 (열 1) D5
C2 (열 2) D4
C3 (열 3) D3

LCD I2C 연결:

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

Arduino UNO Q 코드

Arduino UNO Q에는 함께 작동하는 두 개의 프로세서가 있습니다:

  • STM32 MCU는 키패드를 읽고 LCD를 직접 제어합니다 — 모든 디스플레이 및 입력 로직은 MCU에서 실행됩니다
  • Qualcomm MPU는 Debian Linux를 실행하고 Wi-Fi, Python 및 클라우드 연결을 처리합니다
  • 이 섹션에서는 MCU만 프로그래밍됩니다 — Linux 측은 유휴 상태로 유지됩니다. 이후 섹션에서는 Bridge를 통해 두 프로세서가 함께 작동하는 방법을 보여줍니다.

키를 누르면 LCD에 표시됩니다. *를 누르면 화면이 지워집니다.

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/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; } } } }

빠른 단계

Arduino UNO Q를 처음 사용하시나요? 진행하기 전에 아두이노 우노 Q 시작하기 튜토리얼을 따라 개발 환경을 준비하세요.

  • 연결: 배선도에 표시된 대로 3x4 키패드와 LCD I2C를 Arduino UNO Q MCU에 연결합니다.
  • Arduino App Lab 열기: Arduino App Lab을 실행하고 Arduino UNO Q를 감지할 때까지 기다립니다.
  • 새 앱 만들기: Create New App 버튼을 클릭합니다.
아두이노 app lab에서 Arduino UNO Q에 새 앱 만들기
  • 앱에 이름을 지정합니다. 예: KeypadLcd
  • Create를 클릭하여 확인합니다.
아두이노 app lab 앱 폴더 및 Arduino UNO Q의 파일
  • 스케치 붙여넣기: 위의 MCU 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다. 다른 파일은 기본값으로 유지합니다.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
add sketch 라이브러리 in 아두이노 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
  • 업로드: Arduino App Lab에서 실행 버튼을 클릭합니다.
아두이노 app lab에서 Arduino UNO Q의 실행 버튼 클릭
  • 키패드의 키를 누르면 — 각 문자가 LCD에 나타납니다. *를 눌러 지웁니다.

※ 주의:

LCD에 아무것도 표시되지 않으면 LCD I2C 문제 해결을 확인하세요.

Bridge: Linux + MCU

이 섹션에서는 Arduino UNO Q의 두 프로세서를 모두 프로그래밍하여 Linux 측이 키패드 입력을 모니터링하고 LCD를 원격으로 지울 수 있도록 하는 방법을 보여줍니다:

  • 3x4 키패드 및 LCD는 MCU(STM32)에 연결됩니다 — MCU는 모든 키 감지 및 디스플레이 렌더링을 처리합니다
  • MPU는 키패드 또는 LCD에 직접 액세스할 수 없습니다 — Bridge 함수를 호출하여 입력을 읽고 디스플레이를 제어해야 합니다
  • MPU는 Wi-Fi를 가지고 있습니다 — 전체 Debian Linux를 실행하면서 확인된 항목에 반응하고 인터넷을 통해 경고를 보낼 수 있습니다
  • Arduino_RouterBridge는 두 프로세서 간 RPC 통신을 지원합니다
  • ⚠️ /dev/ttyHS1(Linux) 및 Serial1(MCU)은 라우터에서 예약됨 — 사용자 코드에서 절대 열지 마세요

요약하면: MCU는 키패드 입력을 읽고 LCD에 표시합니다 → MPU는 Bridge를 통해 입력 및 확인된 항목을 모니터링합니다 → MPU는 인터넷을 통해 어디서나 반응하고 알림을 보낼 수 있습니다.

참고: Bridge 스케치에서 keypad.getKey()는 Arduino loop() 내부에서 호출되어 키 누름을 계속 감지합니다 — 이것은 필수이며 Bridge 통신을 방해하지 않습니다.

MCU 코드 (Bridge)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/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 코드 (Bridge)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/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)

빠른 단계

  • 연결: 배선도에 표시된 대로 3x4 키패드와 LCD I2C를 Arduino UNO Q에 연결합니다.
  • Arduino App Lab 열기: Arduino App Lab을 실행하고 보드가 감지될 때까지 기다립니다.
  • 새 앱 만들기: Create New App을 클릭하고 이름을 KeypadLcdBridge로 지정한 다음 Create를 클릭합니다.
  • MCU 스케치 붙여넣기: 위의 MCU Bridge 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
  • Python 코드 붙여넣기: 위의 Python Bridge 코드를 복사하여 앱의 Python 파일에 붙여넣습니다.
  • 업로드: Arduino App Lab에서 실행 버튼을 클릭합니다.
아두이노 app lab에서 Arduino UNO Q의 실행 버튼 클릭
  • 키패드에서 입력하고 #을 누르면 — Python 콘솔의 반응을 확인합니다.

App Lab 콘솔 출력

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

키패드 항목이 확인되었을 때(# 누름) Telegram 알림을 받고 휴대전화에서 원격으로 LCD를 지울 수 있습니다.

MCU 스케치: 이전 Bridge 섹션의 동일한 MCU 스케치를 유지합니다.

Python 코드 (Telegram)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/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)

빠른 단계

  • YOUR_TELEGRAM_BOT_TOKEN을 BotFather에서 받은 실제 봇 토큰으로 바꿉니다.
  • YOUR_CHAT_ID를 Telegram 채팅 ID로 바꿉니다.
  • 이 Python 코드를 앱의 Python 파일에 붙여넣습니다(동일한 MCU 스케치 유지).
  • 실행 버튼을 클릭합니다. 키패드에서 입력하고 #을 누르면 — Telegram 채팅에서 알림을 받습니다.

App Lab 콘솔 출력

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

You can adapt the OpenClaw to this tutorial by refering the instruction on 아두이노 우노 Q - OpenClaw Tutorial

프로젝트 아이디어

Arduino UNO Q에서 키패드와 LCD를 결합하여 많은 창의적인 프로젝트를 구축할 수 있습니다:

  • 원격 PIN 코드 표시: 사용자가 키패드에 PIN을 입력하면 LCD에 나타나고 — #이 누르면 MPU는 입력된 PIN이 포함된 Telegram 경고를 받습니다
  • 스마트 항목 로거: 모든 확인된 키패드 항목은 Linux MPU의 타임스탬프와 함께 기록되고 원격 모니터링을 위해 Telegram으로 전달됩니다
  • 메시지 보드 표시: Python 측에서 Bridge를 통해 텍스트 문자열을 보내면 MCU가 LCD에 표시하고, 키패드를 사용하여 메시지를 순환할 수 있습니다
  • 액세스 코드 검증: Python은 확인된 키패드 항목을 인증된 코드 목록과 비교하여 "액세스 허용" 또는 "거부"를 Telegram으로 보냅니다
  • 다단계 입력 UI: LCD를 사용하여 사용자를 다단계 입력 시퀀스(예: 먼저 코드를 입력한 다음 값을 입력)로 안내합니다 — Python은 단계 상태를 추적합니다

자신을 도전해보세요

Arduino UNO Q의 키패드 및 LCD를 더 활용할 준비가 되셨나요? 이러한 챌린지를 시도해보세요:

  • 쉬움: MCU 스케치를 수정하여 #이 눌리면 입력된 텍스트가 고정 암호와 일치하는지 여부에 따라 두 번째 LCD 행에 "CORRECT" 또는 "WRONG"을 표시합니다.
  • 중급: Python에서 전송된 사용자 정의 메시지를 받아 LCD를 지우고 표시하는 display_message(String) Bridge 함수를 추가합니다 — Linux MPU가 원격으로 화면에 모든 내용을 쓸 수 있도록 합니다.
  • 고급: 완전한 Telegram 제어 액세스 패널을 구축합니다: 사용자가 키패드에 PIN을 입력하면 MPU가 Bridge를 통해 유효성을 검사하고 Telegram 결과를 보내며, 올바르면 릴레이를 활성화합니다. Linux 측의 타임스탬프를 사용하여 모든 시도를 기록합니다.