Arduino UNO Q - Blink LED

Controlling an LED is the classic first step with any Arduino board — and Arduino UNO Q is no different. In this tutorial, you will learn how to write a program for the Arduino UNO Q to turn an LED on and off, and make it blink.

In this tutorial, you will learn:

Arduino UNO Q - LED - Blink

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×LED Kit
1×LED (red)
1×LED Module
1×220Ω Resistor
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: Use the LED Module for easier wiring. It includes an integrated resistor.

Overview of LED

An LED (Light Emitting Diode) is a small light that turns on when current flows through it in the correct direction.

  • Two pins: Anode (+) and Cathode (−)
  • Direction matters: Current must flow from Anode (+) to Cathode (−) for the LED to light up
  • Resistor required: Most LEDs need a current-limiting resistor (typically 220Ω) to prevent damage
  • Control: Connect the Anode (+) to an Arduino digital output pin — set it HIGH to turn on, LOW to turn off
How LED Works

※ NOTE THAT:

Most LEDs require a resistor. You can connect the resistor to the positive side (anode) and the power supply, or to the negative side (cathode) and GND. Some LEDs come with a built-in resistor and do not need an extra one.

Pinout

LED has two pins:

  • Cathode (−) pin: connect to GND (0V)
  • Anode (+) pin: controls the LED's state — HIGH to turn on, LOW to turn off
LED Pinout

How to Program for LED

When you set a pin on the Arduino UNO Q as a digital output, you can program it to control the voltage — either GND or VCC — to switch the LED on or off.

  • Set pin mode to output:
pinMode(9, OUTPUT);
  • Turn the LED off (set pin to LOW):
digitalWrite(9, LOW);
  • Turn the LED on (set pin to HIGH):
digitalWrite(9, HIGH);

Wiring Diagram

The wiring diagram between Arduino UNO Q LED

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

Which pins on the Arduino UNO Q can be used as digital output to control an LED? Pins 0 to 13 and A0 to A5 can all be used as digital output pins.

MCU Code (Direct Arduino Sketch)

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.

Here is the Arduino sketch that blinks an LED connected to pin 9 on the STM32 MCU:

  • Sets pin 9 as a digital output
  • Turns the LED on for 500ms, then off for 500ms — repeating forever
/* * 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-blink-led */ #define LED_PIN 9 // The Arduino UNO Q pin connected to the LED void setup() { pinMode(LED_PIN, OUTPUT); } void loop() { digitalWrite(LED_PIN, HIGH); // turn the LED on delay(500); // wait for 500 milliseconds digitalWrite(LED_PIN, LOW); // turn the LED off delay(500); // wait for 500 milliseconds }

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 LED: Connect the LED and 220Ω resistor to Arduino UNO Q pin 9 according to the wiring diagram above.
  • 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 — this can take several minutes on first launch.
  • 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_BlinkLED
  • 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 that 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 LED connected to pin 9 should blink on and off every 500ms.
    • Pro Tip: Change both delay(500) values to adjust the blink speed — try delay(100) for fast blinking or delay(2000) for slow blinking.

    ※ NOTE THAT:

    • The above code uses the delay() function, which blocks the MCU from doing other tasks while waiting. If your project needs to do multiple things at the same time, see Arduino UNO Q - Blink LED Without Delay.

    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 LED is connected to the MCU (STM32) — the LED is wired to a digital pin on the STM32, not to the MPU. The MCU controls the LED state directly via digitalWrite().
    • The MPU cannot control the LED directly — it must send a request to the MCU via Bridge.call(). The MCU executes the corresponding Bridge.provide_safe() function and sets the LED state.
    • The MPU has Wi-Fi — because the MPU runs full Debian Linux with Wi-Fi, it can connect to the Internet and do things the MCU cannot: receive Telegram commands, call REST APIs, and more.
    • 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 receives the command (e.g., from Telegram) → MPU sends it to MCU → MCU sets the LED state.

    MCU sketch — exposes LED control to the Linux side:

    /* * 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-blink-led */ #include "Arduino_RouterBridge.h" #define LED_PIN 9 void setup() { Bridge.begin(); Monitor.begin(); pinMode(LED_PIN, OUTPUT); Bridge.provide_safe("set_led", set_led); Monitor.println("LED Bridge ready"); } void loop() {} void set_led(int state) { digitalWrite(LED_PIN, state ? HIGH : LOW); }

    Python script (Arduino App Lab) — control the LED 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-blink-led */ from arduino.app_utils import * import time def loop(): Bridge.call("set_led", 1) print("LED ON") time.sleep(0.5) Bridge.call("set_led", 0) print("LED OFF") time.sleep(0.5) 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, 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 Linux side will start blinking the LED via Bridge calls every 500ms.
    • Check the console: Open the Console tab → Python Console subtab to see ON/OFF messages from the Python side.
    • Pro Tip: Change time.sleep(0.5) to any value to control how fast the Linux side blinks the LED.

    App Lab Console Output

    DIYables_Apps
    Stop
    sketch.ino
    1#include "Arduino_RouterBridge.h"
    Serial Monitor
    Python
    LED ON LED OFF LED ON LED OFF

    Telegram Integration

    You can turn the LED on or off remotely over Telegram — send a command from anywhere and the LED responds instantly.

    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 the LED command to the MCU side 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 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-blink-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 == "/on": Bridge.call("set_led", 1) send_message(chat_id, "LED is ON") elif text == "/off": Bridge.call("set_led", 0) send_message(chat_id, "LED is OFF") else: send_message(chat_id, "Commands:\n/on — turn LED on\n/off — turn LED off") time.sleep(1) App.run(user_loop=loop)
    • Note: Replace YOUR_BOT_TOKEN with the token obtained from @BotFather on Telegram.
    • Send /on to your bot to turn the LED on.
    • Send /off to your bot 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: Send /on to your bot and watch the LED turn on. Send /off to turn it off.
    • Pro Tip: Add a /status command to the Python script to report whether the LED is currently on or off.

    App Lab Console Output

    DIYables_Apps
    Stop
    sketch.ino
    1#include "Arduino_RouterBridge.h"
    Serial Monitor
    Python
    [2026-04-29 10:01:12] Telegram: /on [2026-04-29 10:01:12] LED is ON [2026-04-29 10:05:44] Telegram: /off [2026-04-29 10:05:44] LED is OFF [2026-04-29 10:08:30] Telegram: /on [2026-04-29 10:08:30] LED is ON
    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
    /on
    10:15 AM ✓✓
    LED is ON
    10:16 AM
    /off
    10:17 AM ✓✓
    LED is OFF
    10:18 AM

    OpenClaw Integration

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

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

    Application/Project Ideas

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

    • Telegram-controlled night light: Turn a bedroom LED on or off from your phone via Telegram
    • Status indicator: Use the LED to signal whether a process on the Linux side has completed
    • Heartbeat monitor: Blink the LED from the Python side to indicate the App is running and healthy
    • Countdown timer: Blink the LED at increasing speed as a countdown reaches zero
    • Notification light: Flash the LED when a new email or API event is detected on the Linux side

    Challenge Yourself

    Try these challenges with the LED and Arduino UNO Q to level up your skills:

    • Easy: Modify the blink sketch to blink 3 times fast, pause 1 second, then repeat
    • Medium: Add a second LED to the Bridge sketch and create a Telegram command to alternate between them
    • Advanced: Build a Telegram bot that accepts any blink pattern (e.g., /blink 3 500) and makes the LED blink that many times with the given delay

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