Welcome to Jetson ORIN NANO SUPER repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
6. AI Script Peripheral Control
OpenClaw AI Script Writing for Peripheral Control Tutorial
Before starting, please complete the [01-Hardware Configuration], [02-openclaw API-KEY Configuration], [03-openclaw Model Switching], [04-AI Voice Interaction Configuration], [05-Three Dialogue Solution Configuration Tests] under the
Prerequisitesdirectory. If you are currently only using TUI / whatsapp, you can skip04for now. This article assumes the basic environment has been prepared and only expands on "letting AI generate independently runnable scripts".
1. Tutorial Objectives
This article demonstrates through "natural language generation hardware scripts" that OpenClaw can not only directly control peripherals, but also help you save control logic as script files. After completing this tutorial, readers can:
Understand the basic approach to OpenClaw generating hardware control scripts
Communicate with OpenClaw through three methods: whatsapp, TUI, and voice code
Generate four common script types: RGB, servo, temperature and humidity, OLED
2. Hardware Preparation
OpenClaw mainboard
Servo / RGB light strip / OLED / DHT temperature and humidity sensor
[Optional] AI voice module + speaker
Description:
This tutorial does not require connecting all peripherals at once
Connect the corresponding hardware first for the type of script you want to demonstrate
3. Software Preparation
Code entry points that will be used in the tutorial
Script generation skill:
/home/jetson/.openclaw/workspace/skills/script-runner/SKILL.mdDefault script save directory:
/home/jetson/Desktop/Hardware command example directory:
/home/jetson/hardware_hal_demo/Voice entry:
/home/jetson/voice_to_openclaw/src/main.py
The core of this type of capability is not "executing an immediate command", but letting OpenClaw help you generate an independently runnable Python script. According to existing skill agreements:
When users say "generate script", "write a script", "save to desktop", they will prioritize using
script-runnerHardware scripts use
openclaw_libby defaultDefault serial port is
/dev/ttyTHS1Default baud rate is
115200Scripts are usually saved in
/home/jetson/Desktop/
You can understand it as two usage methods:
Method one: Generate script and run immediately
Method two: Only generate script, save to desktop first, modify or run again later
4. Test Script Generation Capability
Before starting this tutorial, please complete one openclaw tui basic dialogue self-check; if you haven't done it yet, see [05-Three Dialogue Solution Configuration Tests]. After confirming OpenClaw can respond normally, enter script generation specific testing.
Terminal input to enter TUI:
openclaw tui
It is recommended to start with the simplest script requirements, for example:
Help me write a script to make RGB red light blink 5 times, save to desktop and run
Generate a script to read temperature and humidity, don't run first
Write a script to make servo 1 swing back and forth between 0, 90, 180 degrees
Generate a script for OLED to display "Hello OpenClaw"
5. Three Solutions for Communicating with OpenClaw
| Solution | Suitable Scenarios | Advantages | Recommended Positioning |
|---|---|---|---|
| Remote requirement sending, classroom demonstrations | Can directly describe "what script to write for me" | Used to demonstrate natural language generation capability | |
| TUI | Local debugging, verify generated results | Easiest to see script generation and run returns | Preferred debugging solution |
| Voice code | Voice interaction, complete AI experience | Can directly verbally describe script requirements | As complete demonstration solution |
If optional AI voice module + speaker are selected, whatsapp dialogue, tui, whatsapp dialogue need to broadcast OpenClaw's reply content. You can run the following program in terminal. AI voice module dialogue does not need to run repeatedly
Modify whether to enable broadcast parameter
xxxxxxxxxx/home/jetson/voice_to_openclaw/.env
xxxxxxxxxxENABLE_TTS=true #This parameter controls whether to broadcast. After modification and saving, run the following program in terminalTerminal input
xxxxxxxxxxcd ~/voice_to_openclawsource .venv/bin/activatepython -m src.openclaw_session_tts
5.1 whatsapp Solution
For whatsapp connection steps, please directly refer to [05-Three Dialogue Solution Configuration Tests]. This section only retains dialogue examples suitable for script generation tutorials.
You can directly dialogue, for example:
Generate a script that make servo swing left and right for 10 seconds and run it

5.2 TUI Solution
If you have completed the TUI self-check in Chapter 0, directly enter the following command in the terminal to continue the dialogue:
xxxxxxxxxxopenclaw tuiThen you can directly enter script requirements, for example:
Help me write a script to control RGB to become blue breathing light and run it

5.3 Voice Code Solution
xxxxxxxxxxRequires optional AI voice interaction module + speaker
For voice module installation, environment configuration, and basic wake-up process, please directly refer to [04-AI Voice Interaction Configuration]. After waking up, you can directly say control content, for example:
Write a script that displays current temperature and humidity to the screen and run it

6. Comprehensive Cases
Note: The following are all dialogue demonstrations using openclaw tui method. You can also choose whatsapp or voice method to complete.
6.1 Case One: RGB Blinking Script
Experimental Objective
Let OpenClaw generate a basic light script to verify the "script creation + peripheral execution" chain.
Effect Description
OpenClaw will organize your natural language requirements into a Python script. After the script is saved to the desktop, it can be run directly or kept for later modification.
Example Instructions
Help me write a script to make RGB red light blink 5 times
Generate a blue breathing light script, save to desktop and run
Write a script for RGB to make a rainbow light effect
6.2 Case Two: Servo Action Script
Experimental Objective
Generate a servo action script to solidify single dialogue actions into repeatable programs.
Effect Description
This type of script is suitable for actions like "nodding", "shaking head", "swinging back and forth", "returning to center", and is also suitable for later expansion into classroom demonstrations or combined projects.
Example Instructions
Write a script for servo 1 to reciprocate between 0, 90, 180 degrees
Generate a servo nodding script
Help me write a script for four servos to all return to 90 degrees
6.3 Case Three: Temperature and Humidity Reading Script
Experimental Objective
Generate a script that reads current temperature and humidity and outputs results.
Effect Description
This type of script is suitable for sensor self-check, data sampling, or subsequent log recording. It is also the most commonly used basic script type when making scheduled tasks later.
Example Instructions
Generate a script to read temperature and humidity, save to desktop
Help me write a script to print current temperature and humidity
Write a script to read DHT data once and run it
6.4 Case Four: OLED Display Script
Experimental Objective
Generate a script that displays text or indicator content to OLED.
Effect Description
This case is suitable for making welcome pages, status pages, simple dashboards, and is also the foundation for later linking with capabilities like temperature/humidity and cameras.
Example Instructions
Help me write a script for OLED to display "Hello OpenClaw"
Generate a script to display temperature and humidity to OLED
Write a script to display a simple status information page
6.5 Case Five: Combined Script
Experimental Objective
Let OpenClaw generate a comprehensive script containing multiple peripheral actions at once.
Effect Description
This type of script can chain together "reading sensors", "displaying to OLED", "controlling RGB", "driving servos", suitable for transitioning from single peripheral control to small project scripts.
Example Instructions
Write a comprehensive script: read temperature and humidity then display to OLED
Generate a script: first light green, then turn servo to 90 degrees
Help me write a script: if temperature is too high, light red and prompt on OLED