Arduino UNO Q - RGB LED

An RGB LED lets you produce virtually any color by mixing red, green, and blue light intensities using PWM signals. In this tutorial, you will learn how to control an RGB LED with the Arduino UNO Q — from simple color cycling to full remote control via Telegram.

In this tutorial, you will learn:

Arduino UNO Q - RGB LED

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×RGB LED Module
1×Alternatively, RGB LED
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 .

Overview of RGB LED

How It Works

An RGB LED contains three separate LEDs — red, green, and blue — in a single package. By mixing different intensities of each color using PWM signals (values 0–255), you can produce any of 256 × 256 × 256 = 16 million colors.

Pinout

An RGB LED has four pins:

  • Common (Cathode−): connect to GND (0V)
  • R: red color control
  • G: green color control
  • B: blue color control
RGB LED Pinout

To keep the wiring simple, use an RGB LED module — it has the current-limiting resistors built in.

RGB LED Module Pinout

※ NOTE THAT:

This tutorial uses a common-cathode RGB LED. If your LED has a common anode, connect the common pin to 3.3V and invert the values: use 255 - R, 255 - G, 255 - B in analogWrite().

Wiring Diagram

  • Wiring diagram — Arduino UNO Q to RGB LED (with separate resistors):
The wiring diagram between Arduino UNO Q RGB LED

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

Use three separate resistors (one per color pin), not a single resistor on the common pin. The three internal LEDs draw different amounts of current, so a shared resistor causes uneven brightness and may damage the LEDs.

  • Wiring diagram — Arduino UNO Q to RGB LED module (resistors built in):
The wiring diagram between Arduino UNO Q RGB LED Module

This image is created using Fritzing. Click to enlarge image

How To Control an RGB LED

To display a specific color (for example, #00979D):

  1. Find your color code — use a color picker
  2. Convert to RGB values — use this tool. Result: R=0, G=151, B=157
  3. Set the pins to output and send the PWM values:
#define PIN_RED 9 #define PIN_GREEN 6 #define PIN_BLUE 3 pinMode(PIN_RED, OUTPUT); pinMode(PIN_GREEN, OUTPUT); pinMode(PIN_BLUE, OUTPUT); analogWrite(PIN_RED, 0); analogWrite(PIN_GREEN, 151); analogWrite(PIN_BLUE, 157);

MCU Code — RGB LED Color Cycling

The Arduino UNO Q has two processors: the STM32 MCU (handles real-time hardware control) and the Qualcomm MPU (runs Debian Linux). In this section, only the STM32 MCU is programmed — the Linux side stays idle. A later section will show how both processors work together.

This example cycles through three colors every second:

  • #00C9CC — Teal (R=0, G=201, B=204)
  • #F7788A — Salmon pink (R=247, G=120, B=138)
  • #34A853 — Green (R=52, G=168, B=83)
/* * 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-rgb-led */ #define PIN_RED 9 // The Arduino UNO Q pin connected to the LED's red pin #define PIN_GREEN 6 // The Arduino UNO Q pin connected to the LED's green pin #define PIN_BLUE 3 // The Arduino UNO Q pin connected to the LED's blue pin void setup() { pinMode(PIN_RED, OUTPUT); // Set red LED pin as an output pinMode(PIN_GREEN, OUTPUT); // Set green LED pin as an output pinMode(PIN_BLUE, OUTPUT); // Set blue LED pin as an output } void loop() { // Set RGB LED to teal color #00C9CC (R = 0, G = 201, B = 204) analogWrite(PIN_RED, 0); analogWrite(PIN_GREEN, 201); analogWrite(PIN_BLUE, 204); delay(1000); // Maintain color for 1 second // Set RGB LED to salmon pink #F7788A (R = 247, G = 120, B = 138) analogWrite(PIN_RED, 247); analogWrite(PIN_GREEN, 120); analogWrite(PIN_BLUE, 138); delay(1000); // Maintain color for 1 second // Set RGB LED to Google green #34A853 (R = 52, G = 168, B = 83) analogWrite(PIN_RED, 52); analogWrite(PIN_GREEN, 168); analogWrite(PIN_BLUE, 83); delay(1000); // Maintain color for 1 second }

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.
  • Wire the RGB LED: Connect the RGB LED module (or LED with resistors) to pins 9, 6, and 3 according to the wiring diagram.
  • Connect: Plug the Arduino UNO Q into your computer with a USB-C cable.
  • 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: DIYables_RgbLED
  • Click Create to confirm.
  • You will see a set of folders and files generated inside your new App.
Arduino App Lab App folders and files on Arduino UNO Q
  • Find the sketch/sketch.ino file — this is where you will paste the MCU sketch.
  • Paste the sketch: Copy the MCU code above and paste it into the sketch file. 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 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
    • Upload: Click the Run button in Arduino App Lab to compile and upload to the STM32.
    Click Run button in Arduino App Lab on Arduino UNO Q
    • Check the LED: The RGB LED should cycle through teal, salmon pink, and green — one second each.
    • Pro Tip: Change the RGB values to display your own colors. Use the color picker to find the right values.

    Cleaner Code with a setColor() Function

    When working with many colors, a setColor() helper function makes the code shorter and easier to read:

    /* * 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-rgb-led */ #define PIN_RED 9 // The Arduino UNO Q pin connected to the LED's red pin #define PIN_GREEN 6 // The Arduino UNO Q pin connected to the LED's green pin #define PIN_BLUE 3 // The Arduino UNO Q pin connected to the LED's blue pin void setup() { pinMode(PIN_RED, OUTPUT); // Set RED LED pin as an output pinMode(PIN_GREEN, OUTPUT); // Set GREEN LED pin as an output pinMode(PIN_BLUE, OUTPUT); // Set BLUE LED pin as an output } void loop() { setColor(0, 201, 204); // teal #00C9CC delay(1000); setColor(247, 120, 138); // salmon pink #F7788A delay(1000); setColor(52, 168, 83); // Google green #34A853 delay(1000); } void setColor(int R, int G, int B) { analogWrite(PIN_RED, R); // Write RED value to RED LED analogWrite(PIN_GREEN, G); // Write GREEN value to GREEN LED analogWrite(PIN_BLUE, B); // Write BLUE value to BLUE LED }
    • Pro Tip: You can build an array of colors and loop through it to create an automatic color-show sequence.

    Linux + MCU Bridge Programming

    The Arduino UNO Q has two processors that work together: the MPU (Qualcomm, runs Debian Linux) and the MCU (STM32, runs Zephyr OS with your Arduino sketch). They communicate using RPC via the Arduino_RouterBridge library — never via raw serial ports.

    • The RGB LED is connected to the MCU (STM32) — wired to PWM-capable digital pins on the STM32. The MCU sets colors using analogWrite().
    • The MPU cannot control the LED directly — it must send commands to the MCU via Bridge.call(). The MCU executes the registered Bridge.provide_safe() functions.
    • The MPU has Wi-Fi — because the MPU runs full Debian Linux with Wi-Fi, it can receive Telegram commands and set any RGB color remotely.
    • Communication: Bridge.call() on the Linux side invokes Bridge.provide_safe() functions on the MCU side
    • ⚠️ Reserved: /dev/ttyHS1 (Linux) and Serial1 (MCU) are used by the Arduino Router — never open them directly

    In short: MPU sends color commands → MCU receives them → MCU sets the RGB LED color in real time.

    MCU sketch — RGB LED with Bridge control:

    /* * 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-rgb-led */ #include "Arduino_RouterBridge.h" #define PIN_RED 9 #define PIN_GREEN 6 #define PIN_BLUE 3 void setColor(int R, int G, int B) { analogWrite(PIN_RED, R); analogWrite(PIN_GREEN, G); analogWrite(PIN_BLUE, B); Monitor.println("Color set to R=" + String(R) + " G=" + String(G) + " B=" + String(B)); } void set_color(int R, int G, int B) { setColor(R, G, B); } void turn_off() { setColor(0, 0, 0); Monitor.println("RGB LED off"); } void setup() { pinMode(PIN_RED, OUTPUT); pinMode(PIN_GREEN, OUTPUT); pinMode(PIN_BLUE, OUTPUT); Bridge.begin(); Monitor.begin(); Bridge.provide_safe("set_color", set_color); Bridge.provide_safe("turn_off", turn_off); Monitor.println("RGB LED Bridge ready"); } void loop() {}

    Python script (Arduino App Lab) — cycle through colors from Linux:

    /* * 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-rgb-led */ from arduino.app_utils import * import time COLORS = [ (0, 201, 204, "Teal"), (247, 120, 138, "Salmon pink"), (52, 168, 83, "Green"), (255, 0, 0, "Red"), (0, 0, 255, "Blue"), (255, 255, 0, "Yellow"), (128, 0, 128, "Purple"), ] def loop(): for r, g, b, name in COLORS: print(f"Setting color: {name} (R={r}, G={g}, B={b})") Bridge.call("set_color", r, g, b) time.sleep(2) print("Turning off RGB LED") Bridge.call("turn_off") time.sleep(2) App.run(user_loop=loop)
    • Note: Make sure Bridge.begin() is called in the MCU sketch and the sketch is uploaded before running the Python script on the Linux side.
    • ⚠️ Warning: Never directly open /dev/ttyHS1 (on Linux) or use Serial1 (on MCU) in your code — these are reserved by the Arduino Router and accessing them will break the Bridge.

    Detailed Instructions

    • Upload the MCU sketch: Open Arduino App Lab, create a new App, paste the Bridge MCU sketch above into sketch/sketch.ino, keep the default libraries (no additional library needed), and click Run.
    • Add the Python script: Paste the Python code above into the Python tab of the same App.
    • Run the App: Click Run — the Python side cycles through 7 colors automatically, then turns the LED off.
    • Check the console: Open the Console tab → Python Console subtab to see which color is active.
    • Pro Tip: Add more colors to the COLORS list in the Python script to expand the color show.

    App Lab Console Output

    DIYables_Apps
    Stop
    sketch.ino
    1#include "Arduino_RouterBridge.h"
    Serial Monitor
    Python
    Setting color: Teal (R=0, G=201, B=204) Setting color: Salmon pink (R=247, G=120, B=138) Setting color: Green (R=52, G=168, B=83) Setting color: Red (R=255, G=0, B=0) Setting color: Blue (R=0, G=0, B=255) Setting color: Yellow (R=255, G=255, B=0) Setting color: Purple (R=128, G=0, B=128) Turning off RGB LED

    Telegram Integration

    You can set any RGB color on your LED remotely via Telegram — just send the R, G, and B values as a command.

    If you do not have a Telegram bot yet, see How to Create a Telegram Bot to get your bot token before continuing.

    This section covers:

    • Running a Python script on the Linux side of Arduino UNO Q to listen for Telegram messages
    • Forwarding color commands to the MCU via Bridge.call()
    • Sending a confirmation reply back to Telegram

    MCU sketch: Keep the same MCU sketch from the previous Bridge section — no changes needed. Make sure it is already uploaded and running on the STM32 before proceeding.

    Python script (Arduino App Lab) — Telegram bot for RGB LED control:

    /* * 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-rgb-led */ 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("/color "): parts = text.split() try: r = int(parts[1]) g = int(parts[2]) b = int(parts[3]) if all(0 <= v <= 255 for v in (r, g, b)): Bridge.call("set_color", r, g, b) send_message(chat_id, f"Color set to R={r}, G={g}, B={b}") else: send_message(chat_id, "Each value must be between 0 and 255") except (ValueError, IndexError): send_message(chat_id, "Usage: /color <R> <G> <B>\nExample: /color 255 0 0") elif text == "/off": Bridge.call("turn_off") send_message(chat_id, "RGB LED turned off") else: send_message(chat_id, "Commands:\n/color <R> <G> <B> — set RGB color\n/off — turn LED off\n\nExamples:\n/color 255 0 0\n/color 0 201 204") time.sleep(1) App.run(user_loop=loop)
    • Note: Replace YOUR_BOT_TOKEN with the token obtained from @BotFather on Telegram.
    • Send /color 255 0 0 to set the LED to red.
    • Send /color 0 201 204 for teal.
    • Send /off to turn the LED off.

    Detailed Instructions

    • Upload the MCU sketch: Use the Bridge MCU sketch from the previous section (upload it first if not already done).
    • Paste the Telegram script: Copy the Python code above into the Python tab of your App in Arduino App Lab.
    • Set your token: Replace YOUR_BOT_TOKEN in the script with your actual bot token.
    • Run the App: Click Run — the bot starts listening for Telegram messages immediately.
    • Test it: Open Telegram, find your bot, and send /color 128 0 128 for purple, or /off to turn it off.
    • Pro Tip: Use a color picker to find any color's RGB values, then send them directly via Telegram.

    App Lab Console Output

    DIYables_Apps
    Stop
    sketch.ino
    1#include "Arduino_RouterBridge.h"
    Serial Monitor
    Python
    [2026-04-29 12:00:01] Telegram: /color 255 0 0 [2026-04-29 12:00:01] Color set to R=255, G=0, B=0 [2026-04-29 12:03:15] Telegram: /color 0 201 204 [2026-04-29 12:03:15] Color set to R=0, G=201, B=204 [2026-04-29 12:06:40] Telegram: /off [2026-04-29 12:06:40] RGB LED turned off
    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
    /color 255 0 0
    10:15 AM ✓✓
    Color set to R=255, G=0, B=0
    10:16 AM
    /color 0 201 204
    10:17 AM ✓✓
    Color set to R=0, G=201, B=204
    10:18 AM
    /off
    10:19 AM ✓✓
    RGB LED turned off
    10:20 AM

    OpenClaw Integration

    OpenClaw integration for Arduino UNO Q RGB LED control is coming soon.

    • Coming Soon: OpenClaw support for controlling RGB LED color on Arduino UNO Q will be covered in a future update.

    Additional Knowledge

    • Common Anode RGB LED: Connect the common pin to 3.3V and invert each channel value: analogWrite(PIN_RED, 255 - R).
    • Color from images: Use the Colors From Image tool to extract color codes from any photo, then convert to RGB values.
    • RGB LED Strip: A series of RGB LEDs connected together forms an RGB LED strip. Addressable strips (like WS2812B) can set each LED individually — see our dedicated tutorials for those.

    Application/Project Ideas

    Here are some project ideas you can build with an RGB LED and Arduino UNO Q:

    • Telegram-controlled mood light: Set the light color in your room from anywhere using Telegram
    • Notification indicator: Use different colors to signal different events (blue = email, red = alert, green = OK)
    • Plant health monitor: Change LED color based on soil moisture level (green = good, yellow = dry, red = needs water)
    • Color-coded weather station: Green for clear sky, blue for rain, red for high temperature alert
    • Disco light show: Cycle through random colors at high speed, triggered via Telegram

    Challenge Yourself

    Try these challenges with the RGB LED and Arduino UNO Q:

    • Easy: Add a fourth color to the cycling sequence in the standalone sketch (e.g., orange: R=255, G=165, B=0)
    • Medium: Extend the Bridge sketch to expose set_red(), set_green(), and set_blue() as separate Bridge functions and control each channel independently from Python
    • Advanced: Build a Telegram bot that accepts named colors (e.g., /purple, /orange) and maps them to RGB values before calling set_color() on the MCU

    ※ 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!