아두이노 우노 Q OLED 128x32

이 튜토리얼에서는 Arduino UNO Q에서 SSD1306 OLED 128x32 디스플레이를 사용하는 방법을 보여드립니다 — 기본 텍스트부터 도형, 이미지, 그리고 원격 Telegram 제어까지.

Arduino UNO Q - oLED 128x32

필요한 하드웨어

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

OLED 128x32 디스플레이 정보

OLED 128x32는 128x64의 더 얇은 버전입니다 — 세로 픽셀이 절반이므로 작은 인클로저, 배지 디스플레이, 최소 UI 패널에 이상적입니다. 동일한 SSD1306 컨트롤러와 동일한 Adafruit 라이브러리를 사용합니다.

OLED 핀아웃

  • GNDGND에 연결
  • VCC — 3.3V 또는 5V에 연결
  • SCL — I2C 클록 신호
  • SDA — I2C 데이터 신호
oLED 사용법 핀아웃

※ 주의:

항상 OLED 모듈에 인쇄된 라벨을 참조하세요 — 제조업체에 따라 핀 순서가 다를 수 있습니다.

배선도

Arduino UNO Q oLED 128x32 배선도

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

OLED 핀Arduino UNO Q 핀
GNDGND
VCC3.3V
SCLSCL
SDASDA

※ 주의:

128x64와 128x32의 코드에서 유일한 차이점은 64 대신 SCREEN_HEIGHT 32입니다. 라이브러리와 배선은 동일합니다.

Arduino UNO Q 코드 — SSD1306 OLED 128x32에서 Hello World

Arduino UNO Q는 두 개의 프로세서를 가지고 있습니다: STM32 MCU (실시간 하드웨어 제어 처리)와 Qualcomm MPU (Debian Linux 실행). 이 섹션에서는 STM32 MCU만 프로그래밍됩니다 — Linux 측은 유휴 상태입니다. 나중 섹션에서는 두 프로세서가 함께 작동하는 방법을 보여줍니다.

아래 스케치는 서로 다른 크기의 두 개의 텍스트를 OLED에 표시합니다.

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); oled.clearDisplay(); // Row 1 — size 1 oled.setTextSize(1); oled.setTextColor(WHITE); oled.setCursor(0, 0); oled.println(F("Hello, World!")); // Row 2 — size 2 oled.setTextSize(2); oled.setCursor(0, 14); oled.println(F("DIYables")); oled.display(); } void loop() {}

빠른 단계

  • Arduino UNO Q를 처음 사용하시나요? 계속하기 전에 아두이노 우노 Q 시작하기 튜토리얼을 따라 개발 환경을 준비하세요.
  • OLED 배선: GND→GND, VCC→3.3V, SCL→SCL, SDA→SDA에 연결합니다.
  • 연결: USB-C 케이블로 Arduino UNO Q를 컴퓨터에 연결합니다.
  • Arduino App Lab 열기: Arduino App Lab을 실행하고 Arduino UNO Q를 감지할 때까지 기다립니다.
  • 새 앱 만들기: 새 앱 만들기 버튼을 클릭합니다.
Arduino UNO Q에서 아두이노 app lab에 새 앱 만들기
  • 앱에 이름을 지정합니다(예: DIYables_OLED_128x32).
  • 만들기를 클릭하여 확인합니다.
  • 새 앱 내에서 폴더 및 파일 집합이 생성됩니다.
Arduino UNO Q에서 아두이노 app lab 앱 폴더 및 파일
  • sketch/sketch.ino 파일을 찾습니다 — 여기가 MCU 스케치를 붙여 넣을 위치입니다.
  • 스케치 붙여넣기: 위의 MCU 코드를 복사하여 스케치 파일에 붙여넣습니다.
    • 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 Arduino_RouterBridge created by Arduino 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
    Arduino_RouterBridge Arduino

    This library provides a simple RPC bridge for Arduino UNO Q boards, allowing communication between the board and other devices using MsgPack serialization.

    0.4.1
    Install
    More Info
    • Search for Adafruit SSD1306 created by Adafruit 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
    Adafruit SSD1306 Adafruit

    SSD1306 oled driver library for monochrome 128x64 and 128x32 displays

    2.5.9
    Install
    More Info
    • 업로드: Arduino App Lab에서 실행 버튼을 클릭하여 STM32로 컴파일 및 업로드합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED를 보면 첫 번째 행에 "Hello, World!"가 표시되고 두 번째 행에 "DIYables"가 더 큰 텍스트로 표시됩니다!

    Arduino UNO Q 코드 — SSD1306 OLED 128x32에 텍스트 표시

    이 예제는 다양한 텍스트 크기와 정수, 소수, 16진수를 OLED에 표시하는 방법을 보여줍니다.

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); // ── Text size demo ── oled.clearDisplay(); oled.setTextColor(WHITE); oled.setTextSize(1); oled.setCursor(0, 0); oled.println(F("Size 1: Arduino UNO Q")); oled.setTextSize(2); oled.setCursor(0, 14); oled.println(F("Size 2")); oled.display(); delay(3000); // ── Integer ── oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0); oled.print(F("Integer: ")); oled.println(12345); oled.display(); delay(3000); // ── Float ── oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0); oled.print(F("Float: ")); oled.println(3.14); oled.display(); delay(3000); // ── Hexadecimal ── oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0); oled.print(F("Hex: ")); oled.println(255, HEX); oled.display(); delay(3000); } void loop() {}

    빠른 단계

    • 위의 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Arduino App Lab에서 실행 버튼을 클릭합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED는 텍스트 크기 데모를 순환한 다음 정수, 소수, 16진수를 표시합니다.

    유용한 표시 함수 참조

    자주 사용되는 SSD1306 OLED 함수에 대한 빠른 참조:

    • oled.clearDisplay() — 프레임 버퍼 지우기 (모든 픽셀 끄기)
    • oled.display() — 버퍼를 화면으로 푸시 — 모든 그리기 호출 후 필수
    • oled.drawPixel(x, y, color) — 단일 픽셀 설정 또는 지우기
    • oled.setTextSize(n) — 폰트를 *n* 배수로 스케일 (1 = 6×8 px, 2 = 12×16 px, …)
    • oled.setCursor(x, y) — 텍스트 커서를 픽셀 좌표 *(x, y)* 로 이동
    • oled.setTextColor(WHITE) — 텍스트 전경만 (투명 배경)
    • oled.setTextColor(BLACK, WHITE) — 명시적 배경이 있는 텍스트
    • oled.println("message") — 문자열 인쇄 및 다음 줄로 이동
    • oled.println(number) — 정수를 10진수로 인쇄
    • oled.println(number, HEX) — 정수를 16진수로 인쇄
    • oled.startscrollright(start, stop) — 페이지 간 오른쪽으로 하드웨어 스크롤
    • oled.startscrollleft(start, stop) — 왼쪽으로 하드웨어 스크롤
    • oled.startscrolldiagright(start, stop) — 대각선 오른쪽 스크롤
    • oled.startscrolldiagleft(start, stop) — 대각선 왼쪽 스크롤
    • oled.stopscroll() — 활성 하드웨어 스크롤 중지
    • oled.setContrast(value) — 밝기 조정 (0–255)
    • oled.dim(true/false) — 빠른 어둡게 전환
    • oled.invertDisplay(true/false) — 하드웨어 수준 색상 반전

    Arduino UNO Q 코드 — SSD1306 OLED 128x32에 도형 그리기

    Adafruit SSD1306 라이브러리는 Adafruit_GFX에서 상속되어 픽셀, 선, 사각형, 원, 삼각형, 둥근 사각형을 제공합니다. 아래 스케치는 모든 도형을 순환합니다 — 좌표는 32픽셀 높이에 맞게 조정됩니다.

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); oled.clearDisplay(); oled.display(); } void loop() { // ── Dotted horizontal line ── oled.clearDisplay(); for (int i = 0; i < SCREEN_WIDTH; i += 4) oled.drawPixel(i, SCREEN_HEIGHT / 2, WHITE); oled.display(); delay(2000); // ── Diagonal lines ── oled.clearDisplay(); oled.drawLine(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, WHITE); oled.drawLine(SCREEN_WIDTH - 1, 0, 0, SCREEN_HEIGHT - 1, WHITE); oled.display(); delay(2000); // ── Rectangle ── oled.clearDisplay(); oled.drawRect(4, 4, 120, 24, WHITE); oled.display(); delay(2000); // ── Filled rectangle ── oled.clearDisplay(); oled.fillRect(4, 4, 120, 24, WHITE); oled.display(); delay(2000); // ── Rounded rectangle ── oled.clearDisplay(); oled.drawRoundRect(4, 4, 120, 24, 6, WHITE); oled.display(); delay(2000); // ── Filled rounded rectangle ── oled.clearDisplay(); oled.fillRoundRect(4, 4, 120, 24, 6, WHITE); oled.display(); delay(2000); // ── Circle ── oled.clearDisplay(); oled.drawCircle(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 14, WHITE); oled.display(); delay(2000); // ── Filled circle ── oled.clearDisplay(); oled.fillCircle(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 14, WHITE); oled.display(); delay(2000); // ── Triangle ── oled.clearDisplay(); oled.drawTriangle(64, 1, 10, 30, 118, 30, WHITE); oled.display(); delay(2000); // ── Filled triangle ── oled.clearDisplay(); oled.fillTriangle(64, 1, 10, 30, 118, 30, WHITE); oled.display(); delay(2000); }

    빠른 단계

    • 위의 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Arduino App Lab에서 실행 버튼을 클릭합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED가 모든 도형을 순환하는 것을 보세요 — 픽셀, 선, 사각형, 원, 둥근 사각형, 삼각형!

    Arduino UNO Q 코드 — SSD1306 OLED 128x32에서 하드웨어 스크롤

    SSD1306은 CPU 작업 없이 콘텐츠를 이동시키는 내장 하드웨어 스크롤 엔진을 가지고 있습니다. 라이브러리는 네 가지 스크롤 방향을 제공합니다: 오른쪽, 왼쪽, 대각선 오른쪽, 대각선 왼쪽.

    ※ 주의:

    콘텐츠를 스크롤 시작 전에 OLED로 전송하려면 항상 oled.display()를 호출하세요. 새 콘텐츠를 그리기 전에 stopscroll()을 호출하세요. 128x32 디스플레이의 경우 0x00, 0x07 대신 페이지 범위 0x00, 0x03을 사용하세요.

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); oled.clearDisplay(); oled.setTextSize(2); oled.setTextColor(WHITE); oled.setCursor(10, 8); oled.println(F("DIYables")); oled.display(); } void loop() { // Scroll right oled.startscrollright(0x00, 0x03); delay(3000); oled.stopscroll(); delay(500); // Scroll left oled.startscrollleft(0x00, 0x03); delay(3000); oled.stopscroll(); delay(500); // Diagonal scroll right oled.startscrolldiagright(0x00, 0x03); delay(3000); oled.stopscroll(); delay(500); // Diagonal scroll left oled.startscrolldiagleft(0x00, 0x03); delay(3000); oled.stopscroll(); delay(500); }

    빠른 단계

    • 위의 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Arduino App Lab에서 실행 버튼을 클릭합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED는 "DIYables"를 오른쪽, 왼쪽, 대각선 오른쪽, 대각선 왼쪽으로 계속 반복하며 스크롤합니다.

    Arduino UNO Q 코드 — SSD1306 OLED 128x32에 비트맵 이미지 표시

    OLED에 비트맵을 표시하려면 먼저 이미지를 C 바이트 배열로 변환해야 합니다. 무료 Image to Bitmap Converter 도구를 사용하세요:

    1. 이미지 파일 업로드 (PNG, JPG, BMP 등).
    2. 캔버스 크기를 128×32 (또는 더 작게) 설정합니다.
    3. Arduino code 를 출력 형식으로 선택합니다.
    4. 생성된 배열을 스케치에 복사합니다.
    image to bitmap array

    아래 스케치는 먼저 16×16 하트 아이콘을 표시한 다음 72×32 DIYables 아이콘으로 전환합니다 — 둘 다 코드에 바이트 배열로 저장됩니다:

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // 16x16 heart bitmap const unsigned char heart16x16[] PROGMEM = { 0x00, 0x00, 0x03, 0xc0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0x3f, 0xfc, 0x1f, 0xf8, 0x0f, 0xf0, 0x03, 0xc0, 0x00, 0x00 }; // 72x32 DIYables icon bitmap const unsigned char bitmap_DIYables[] PROGMEM = { 0x00, 0x0f, 0xff, 0xff, 0x8f, 0xf8, 0x07, 0x38, 0x07, 0x00, 0x0f, 0xff, 0xff, 0x8f, 0xfe, 0x07, 0x1c, 0x0e, 0x00, 0x0f, 0xff, 0xff, 0x8f, 0xff, 0x07, 0x1c, 0x1c, 0x00, 0x0f, 0xff, 0xff, 0x8e, 0x07, 0x87, 0x0e, 0x1c, 0x00, 0x0f, 0xff, 0xff, 0x8e, 0x03, 0xc7, 0x0f, 0x38, 0x00, 0x0f, 0xff, 0xff, 0x8e, 0x01, 0xc7, 0x07, 0x38, 0x00, 0x0f, 0xff, 0xff, 0x8e, 0x01, 0xc7, 0x03, 0xf0, 0xf0, 0x0f, 0xff, 0xff, 0x8e, 0x01, 0xc7, 0x03, 0xe0, 0xfc, 0x0f, 0xff, 0xff, 0x8e, 0x01, 0xc7, 0x01, 0xe0, 0xfe, 0x0f, 0xff, 0xff, 0x8e, 0x03, 0xc7, 0x01, 0xc0, 0xff, 0x8f, 0xff, 0xff, 0x8e, 0x03, 0x87, 0x01, 0xc0, 0xff, 0x8f, 0xff, 0xff, 0x8e, 0x0f, 0x87, 0x01, 0xc0, 0xff, 0xcf, 0xff, 0xff, 0x8f, 0xff, 0x07, 0x01, 0xc0, 0xff, 0xef, 0xff, 0xff, 0x8f, 0xfc, 0x07, 0x01, 0xc0, 0xff, 0xef, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0x0e, 0x0c, 0x0c, 0xc3, 0x07, 0xff, 0xef, 0xff, 0xfe, 0x0f, 0xec, 0xec, 0x99, 0x7f, 0xff, 0xef, 0xff, 0xfe, 0x0f, 0x04, 0xe4, 0x81, 0x0f, 0xff, 0xcf, 0xff, 0xfc, 0x0e, 0x32, 0xe4, 0x9f, 0xc7, 0xff, 0x8f, 0xff, 0xf8, 0x0e, 0x32, 0x4c, 0x9b, 0x67, 0xff, 0x0f, 0xff, 0xf0, 0x0e, 0x04, 0x0c, 0xc3, 0x0f, 0xfe, 0x0f, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff }; void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); // Show heart icon centered oled.clearDisplay(); oled.drawBitmap( (SCREEN_WIDTH - 16) / 2, (SCREEN_HEIGHT - 16) / 2, heart16x16, 16, 16, WHITE); oled.display(); delay(3000); // Show DIYables icon centered (72x32 fits exactly in height) oled.clearDisplay(); oled.drawBitmap( (SCREEN_WIDTH - 72) / 2, 0, bitmap_DIYables, 72, 32, WHITE); oled.display(); } void loop() {}

    빠른 단계

    • 위의 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Arduino App Lab에서 실행 버튼을 클릭합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED에 하트 아이콘이 3초 동안 표시된 다음 DIYables 아이콘으로 전환됩니다.

    ※ 주의:

    비트맵 크기는 화면 해상도 (128×32)를 초과해서는 안 됩니다. 너비는 ≤ 128, 높이는 ≤ 32를 유지하세요.

    Arduino UNO Q 코드 — SSD1306 OLED 128x32에서 명도 제어

    SSD1306은 256 명도 수준 (0–255)을 지원합니다. 세밀한 제어를 위해 setContrast()를 사용하고 빠른 밝기 전환을 위해 dim()을 사용하세요.

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); // Draw a checkerboard test pattern oled.clearDisplay(); for (int x = 0; x < SCREEN_WIDTH; x += 8) for (int y = 0; y < SCREEN_HEIGHT; y += 8) if ((x / 8 + y / 8) % 2 == 0) oled.fillRect(x, y, 8, 8, WHITE); oled.display(); delay(2000); } void loop() { // Ramp up: 0 → 255 for (int c = 0; c <= 255; c += 5) { oled.setContrast((uint8_t)c); delay(30); } delay(1000); // Ramp down: 255 → 0 for (int c = 255; c >= 0; c -= 5) { oled.setContrast((uint8_t)c); delay(30); } delay(1000); // Quick dim toggle oled.dim(true); // minimum brightness delay(2000); oled.dim(false); // restore delay(2000); }

    빠른 단계

    • 위의 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Arduino App Lab에서 실행 버튼을 클릭합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED 밝기가 올라갔다가 내려가는 것을 보세요, 그 다음 어둡게 켜짐/꺼짐 사이클이 진행됩니다.

    Arduino UNO Q 코드 — SSD1306 OLED 128x32에 사용자 정의 외부 폰트

    Adafruit GFX 라이브러리에는 많은 FreeFont 글꼴이 포함되어 있습니다. 높이가 32픽셀만 있으므로 작은 폰트 (9pt)는 두 줄을 허용하고 더 큰 폰트 (12pt)는 한 행을 채웁니다.

    ※ 주의:

    외부 폰트가 활성화되면 커서 Y 좌표는 왼쪽 위 모서리가 아닌 텍스트 기선 을 나타냅니다. 이는 내장 5×7 폰트와 다릅니다.

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <Fonts/FreeSerif9pt7b.h> #include <Fonts/FreeSansBold12pt7b.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); void setup() { Monitor.begin(9600); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println(F("SSD1306 allocation failed")); for (;;); } delay(2000); oled.clearDisplay(); oled.display(); } void loop() { // ── Built-in 5×7 font ── oled.clearDisplay(); oled.setFont(NULL); oled.setTextSize(1); oled.setTextColor(WHITE); oled.setCursor(0, 0); oled.println(F("Built-in 5x7 font")); oled.setTextSize(2); oled.setCursor(0, 14); oled.println(F("DIYables")); oled.display(); delay(3000); // ── FreeSerif 9pt ── // With 32px height, Y baseline for two rows: ~12 and ~28 oled.clearDisplay(); oled.setFont(&FreeSerif9pt7b); oled.setTextSize(1); oled.setTextColor(WHITE); oled.setCursor(0, 12); // Y = baseline oled.println(F("FreeSerif 9pt")); oled.setCursor(0, 28); oled.println(F("DIYables")); oled.display(); delay(3000); // ── FreeSansBold 12pt ── // With 32px height, only one row fits comfortably oled.clearDisplay(); oled.setFont(&FreeSansBold12pt7b); oled.setTextSize(1); oled.setTextColor(WHITE); oled.setCursor(0, 22); // Y = baseline (≈18px ascent) oled.println(F("SansBold 12pt")); oled.display(); delay(3000); }

    빠른 단계

    • 위의 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Arduino App Lab에서 실행 버튼을 클릭합니다.
    Arduino UNO Q에서 아두이노 app lab 실행 버튼 클릭

    OLED는 내장 폰트, FreeSerif 9pt (두 줄), FreeSansBold 12pt (한 행)를 순환합니다.

    Linux + MCU Bridge 프로그래밍

    Arduino UNO Q는 함께 작동하는 두 개의 프로세서를 가지고 있습니다: MPU (Qualcomm, Debian Linux 실행)와 MCU (STM32, Arduino 스케치를 실행하는 Zephyr OS). 그들은 Arduino_RouterBridge 라이브러리를 통해 RPC 를 사용하여 통신합니다 — 절대 원시 직렬 포트를 통해서가 아닙니다.

    • OLED는 MCU (STM32)에 연결됩니다 — I2C (SCL/SDA)를 통해. MCU만 직접 제어할 수 있습니다.
    • MPU는 OLED를 직접 제어할 수 없습니다Bridge.call("display_text", "text")를 호출하면 OLED를 업데이트하고 모니터에 결과를 인쇄합니다.
    • MPU는 Wi-Fi를 가지고 있습니다 — MPU는 Wi-Fi를 포함한 전체 Debian Linux를 실행하므로 Telegram 명령을 받을 수 있고 OLED에 모든 메시지를 원격으로 표시할 수 있습니다.
    • 통신: Linux 측의 Bridge.call()은 MCU 측의 Bridge.provide_safe() 함수를 호출합니다 (OLED 쓰기는 하드웨어 API 호출이므로).
    • ⚠️ 예약됨: /dev/ttyHS1 (Linux)과 Serial1 (MCU)은 Arduino Router에서 사용됩니다 — 절대 직접 열지 마세요.

    MCU 스케치 — Bridge 및 모니터 출력이 있는 OLED 128x32:

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ #include "Arduino_RouterBridge.h" #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 32 Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); String current_text = ""; void display_text(String text) { current_text = text; oled.clearDisplay(); oled.setTextSize(1); oled.setTextColor(WHITE); oled.setCursor(0, 0); oled.println(text); oled.display(); Monitor.println("OLED: " + text); } void clear_oled() { current_text = ""; oled.clearDisplay(); oled.display(); Monitor.println("OLED cleared"); } void get_status() { Monitor.println("Text: " + current_text); } void setup() { Bridge.begin(); Monitor.begin(); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println("OLED init failed"); while (true); } delay(1000); oled.clearDisplay(); oled.setTextSize(1); oled.setTextColor(WHITE); oled.setCursor(0, 0); oled.println("Bridge Ready"); oled.display(); Bridge.provide_safe("display_text", display_text); Bridge.provide_safe("clear_oled", clear_oled); Bridge.provide("get_status", get_status); Monitor.println("OLED 128x32 Bridge ready"); } void loop() {}

    Python 스크립트 (Arduino App Lab) — Linux에서 OLED 128x32에 텍스트 표시:

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ from arduino.app_utils import * import time def loop(): result = Bridge.call("display_text", "Hello UNO Q\nOLED 128x32") print(result) time.sleep(3) result = Bridge.call("clear_oled") print(result) time.sleep(1) result = Bridge.call("display_text", "DIYables.io") print(result) time.sleep(3) App.run(user_loop=loop)

    빠른 단계

    • 새 앱 만들기: Arduino App Lab을 열고, 새 앱 만들기를 클릭하고, 이름을 DIYables_OLED_128x32_Bridge로 지정하고, 만들기를 클릭합니다.
    • MCU 스케치 붙여넣기: 위의 Bridge MCU 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
    • Python 스크립트 붙여넣기: 위의 Python 코드를 복사하여 앱의 Python 파일에 붙여넣습니다.
    • 앱 실행: 실행 버튼을 클릭하세요 — Python 측은 OLED의 메시지를 순환합니다.

    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
    OLED 128x32 Bridge ready OLED: Hello UNO Q OLED cleared OLED: DIYables.io

    Telegram 통합

    Telegram을 통해 어디서나 원격으로 OLED 128x32에 텍스트를 표시합니다.

    Telegram 봇이 아직 없다면 계속하기 전에 아두이노 우노 Q - 텔레그램 봇을 참조하여 봇 토큰을 가져오세요.

    MCU 스케치: 이전 Bridge 섹션에서 동일한 MCU 스케치 유지 — 변경 없음. STM32에서 이미 업로드되고 실행 중인지 확인한 후 진행하세요.

    Python 스크립트 (Arduino App Lab) — OLED 128x32용 Telegram 봇:

    /* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-oled-128x32 */ from arduino.app_utils import * import requests import time BOT_TOKEN = "YOUR_BOT_TOKEN" API_URL = f"https://api.telegram.org/bot{BOT_TOKEN}" last_update_id = 0 def send_message(chat_id, text): requests.post(f"{API_URL}/sendMessage", json={"chat_id": chat_id, "text": text}) def get_updates(): global last_update_id resp = requests.get(f"{API_URL}/getUpdates", params={"offset": last_update_id + 1, "timeout": 5}) return resp.json().get("result", []) def loop(): global last_update_id updates = get_updates() for update in updates: last_update_id = update["update_id"] msg = update.get("message", {}) chat_id = msg.get("chat", {}).get("id") text = msg.get("text", "").strip() if text.startswith("/display "): content = text[9:] result = Bridge.call("display_text", content) print(f"[Telegram] /display: {content}") send_message(chat_id, result) elif text == "/clear": result = Bridge.call("clear_oled") print(f"[Telegram] /clear") send_message(chat_id, result) elif text == "/status": result = Bridge.call("get_status") print(f"[Telegram] /status: {result}") send_message(chat_id, result) else: send_message(chat_id, "Commands:\n/display <text> — show text on OLED\n/clear — clear the OLED\n/status — show current OLED content") App.run(user_loop=loop)
    • 참고: Telegram의 @BotFather에서 받은 토큰으로 YOUR_BOT_TOKEN을 바꾸세요.
    • /display Hello 전송 — OLED에 나타납니다.
    • /clear 전송 — OLED를 지웁니다.
    • /status 전송 — 봇이 현재 OLED 텍스트로 응답합니다.

    App Lab 콘솔 출력

    DIYables_Apps
    Stop
    sketch.ino
    1#include "Arduino_RouterBridge.h"
    Serial Monitor
    Python
    [2026-04-29 12:00:01] Telegram: /display Arduino UNO Q [2026-04-29 12:00:01] OLED: Arduino UNO Q [2026-04-29 12:05:10] Telegram: /status [2026-04-29 12:05:10] Text: Arduino UNO Q [2026-04-29 12:10:20] Telegram: /clear [2026-04-29 12:10:20] OLED cleared
    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
    /display Arduino UNO Q
    10:15 AM ✓✓
    OLED: Arduino UNO Q
    10:16 AM
    /status
    10:17 AM ✓✓
    Text: Arduino UNO Q
    10:18 AM
    /clear
    10:19 AM ✓✓
    OLED cleared
    10:20 AM

    OpenClaw 통합

    이 튜토리얼을 OpenClaw에 맞게 조정할 수 있습니다. 아두이노 우노 Q - OpenClaw 튜토리얼의 지침을 참조하세요.

    애플리케이션/프로젝트 아이디어

    • 착용식 상태 디스플레이: 얇은 128x32을 배지 또는 팔찌에 맞게 실시간 센서 판독값을 표시하기
    • 한 줄 경고 디스플레이: 마지막 Telegram 경고 메시지를 항상 OLED에 표시
    • Wi-Fi 네트워크 정보: Linux 측에서 연결된 SSID 및 IP 주소를 좁은 OLED에 표시
    • 최소 대시보드: 온도 및 습도를 나란히 두 텍스트 행에서 사용
    • 알림 티커: 수신 Telegram 메시지를 128x32 화면에서 스크롤

    도전과제

    • 쉬움: 공백 없이 /display 전송 — 오류 처리 추가로 "Usage: /display " 응답
    • 중간: 메시지를 각각 21자의 두 줄로 분할하고 setCursor(0, 0)setCursor(0, 16)을 사용하여 128x32에 둘 다 표시
    • 고급: MCU 측의 루프에서 clearDisplay()/display()를 사용하여 OLED를 3번 깜빡이는 /blink 명령 추가