Arduino UNO Q - Actuator

In this guide, you will learn how to control a linear actuator with Arduino UNO Q and the Motor Shield Rev3. You will learn:

This tutorial covers linear actuators without feedback. For position control, see Arduino UNO Q - Actuator with Feedback.

Arduino UNO Q Actuator

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×Linear Actuator
1×Motor Shield for Arduino
1×12V Power Adapter
1×DC Power Jack
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 Linear Actuator

Linear Actuator Extend Retract

A linear actuator converts electrical energy into linear motion. It can extend and retract, making it useful for pushing, pulling, lifting, or clamping.

Linear Actuator Pinout

A linear actuator has two wires:

  • Positive wire (often red)
  • Negative wire (often black)
Linear Actuator Pinout

How It Works

For a 12V linear actuator:

  • Connect 12V to positive, GND to negative → actuator extends fully at full speed until it reaches its limit.
  • Connect 12V to negative, GND to positive → actuator retracts fully at full speed until it reaches its limit.
  • Connect both wires to GND → actuator stops.

The Motor Shield Rev3 handles these polarity switches for you. The DIYables_DC_Motor library controls direction and speed — use motor.run(MOTOR_FORWARD, 255) to extend and motor.run(MOTOR_BACKWARD, 255) to retract at full speed. Call motor.brake() to stop.

How to control linear actuator

※ NOTE THAT:

Unlike regular DC motors, linear actuators can hold their position even without power when carrying a load.

If you are not familiar with the Motor Shield Rev3 (pinout, how it works, and how to program it), see the Arduino UNO Q - DC Motor Shield tutorial first.

Wiring Diagram

The wiring diagram between Arduino UNO Q Actuator Motor Shield

This image is created using Fritzing. Click to enlarge image

MCU Code

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.

The code below extends the actuator for 20 seconds, then retracts it for 20 seconds, repeatedly:

/* * 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-actuator */ #include <DIYables_DC_Motor.h> DIYables_DC_Motor motor(MOTOR_CH_A); void setup() { motor.begin(); } void loop() { // extend the actuator at full speed motor.run(MOTOR_FORWARD, 255); delay(20000); // actuator stops automatically at its limit // retract the actuator at full speed motor.run(MOTOR_BACKWARD, 255); delay(20000); // actuator stops automatically at its limit }

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.
  • Stack the shield: Firmly press the Motor Shield Rev3 onto the Arduino UNO Q headers. Connect the actuator wires to the Channel A screw terminals. Connect the 12V power supply to the shield's power screw terminals.
  • 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_Actuator
  • 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 DIYables_DC_Motor 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_DC_Motor DIYables.io

    Easy-to-use library for controlling DC motors via the Arduino Motor Shield Rev3 (L298P). Supports both Channel A and Channel B with direction control, PWM speed, brake, and current sensing. Custom pin assignments also supported.

    1.0.0
    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
    • Test: The actuator should extend fully, pause, then retract fully, repeatedly.

    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 Motor Shield Rev3 and actuator are controlled by the MCU (STM32) — the DIYables_DC_Motor library drives the actuator via Channel A.
    • The MPU cannot control the actuator directly — it calls Bridge.call("actuator_extend"), Bridge.call("actuator_retract"), or Bridge.call("actuator_stop") on the MCU.
    • The MPU has Wi-Fi — because the MPU runs full Debian Linux with Wi-Fi, it can accept Telegram commands to control the actuator remotely.
    • Communication: Bridge.call() on the Linux side invokes Bridge.provide_safe() on the MCU side (since motor.run() and motor.brake() use hardware APIs)
    • ⚠️ Reserved: /dev/ttyHS1 (Linux) and Serial1 (MCU) are used by the Arduino Router — never open them directly

    In short: MPU sends actuator command → MCU drives Motor Shield → actuator extends or retracts.

    MCU sketch — actuator control with 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-actuator */ #include "Arduino_RouterBridge.h" #include <DIYables_DC_Motor.h> DIYables_DC_Motor motor(MOTOR_CH_A); void actuator_extend() { motor.run(MOTOR_FORWARD, 255); Monitor.println("Actuator: EXTENDING"); } void actuator_retract() { motor.run(MOTOR_BACKWARD, 255); Monitor.println("Actuator: RETRACTING"); } void actuator_stop() { motor.brake(); Monitor.println("Actuator: STOPPED"); } void setup() { Bridge.begin(); Monitor.begin(); motor.begin(); motor.brake(); Bridge.provide_safe("actuator_extend", actuator_extend); Bridge.provide_safe("actuator_retract", actuator_retract); Bridge.provide_safe("actuator_stop", actuator_stop); Monitor.println("Actuator Bridge ready"); } void loop() {}

    Python script (Arduino App Lab) — extend, pause, retract, pause cycle:

    /* * 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-actuator */ from arduino.app_utils import * import time def loop(): Bridge.call("actuator_extend") time.sleep(20) Bridge.call("actuator_stop") time.sleep(1) Bridge.call("actuator_retract") time.sleep(20) Bridge.call("actuator_stop") time.sleep(1) 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 into sketch/sketch.ino, install both DIYables_DC_Motor and Arduino_RouterBridge libraries, 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 — Python extends and retracts the actuator in a cycle.
    • Check the console: Open the Console tab → MCU Monitor subtab to see actuator state.

    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
    Actuator Bridge ready Actuator: EXTENDING Actuator: STOPPED Actuator: RETRACTING Actuator: STOPPED

    Telegram Integration

    Control the actuator remotely via Telegram with /extend, /retract, and /stop commands.

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

    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 actuator 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-actuator */ 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 == "/extend": Bridge.call("actuator_extend") send_message(chat_id, "Actuator is EXTENDING.") elif text == "/retract": Bridge.call("actuator_retract") send_message(chat_id, "Actuator is RETRACTING.") elif text == "/stop": Bridge.call("actuator_stop") send_message(chat_id, "Actuator STOPPED.") else: send_message(chat_id, "Commands:\n/extend — extend actuator\n/retract — retract actuator\n/stop — stop actuator") time.sleep(0.5) App.run(user_loop=loop)
    • Note: Replace YOUR_BOT_TOKEN with the token obtained from @BotFather on Telegram.
    • Send /extend, /retract, or /stop to control the actuator.

    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.
    • Test it: Send /extend, /retract, and /stop to control the actuator.

    App Lab Console Output

    DIYables_Apps
    Stop
    sketch.ino
    1#include "Arduino_RouterBridge.h"
    Serial Monitor
    Python
    [2026-04-29 12:00:01] Telegram: /extend [2026-04-29 12:00:01] Actuator is EXTENDING. [2026-04-29 12:00:15] Telegram: /stop [2026-04-29 12:00:15] Actuator STOPPED. [2026-04-29 12:01:00] Telegram: /retract [2026-04-29 12:01:00] Actuator is RETRACTING.
    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
    /extend
    10:15 AM ✓✓
    Actuator is EXTENDING.
    10:16 AM
    /stop
    10:17 AM ✓✓
    Actuator STOPPED.
    10:18 AM
    /retract
    10:19 AM ✓✓
    Actuator is RETRACTING.
    10:20 AM

    OpenClaw Integration

    OpenClaw integration for Arduino UNO Q actuator control is coming soon.

    • Coming Soon: OpenClaw support for this project on Arduino UNO Q will be covered in a future update.

    Application/Project Ideas

    • Automated gate: Extend to open and retract to close a physical gate
    • Adjustable desk: Control desk height with Telegram commands
    • Solar panel tracker: Tilt a solar panel toward the sun using motion-triggered actuator
    • Camera slider: Drive a camera along a linear track for smooth video shots

    Challenge Yourself

    • Easy: Change the extension and retraction time from 20 seconds to 10 seconds
    • Medium: Add a /stop_after_extend Telegram command that extends, waits 10 seconds, then stops automatically
    • Advanced: Combine with a limit switch to detect when the actuator reaches its full extent

    Function References

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