Welcome to Raspberry Pi 5 repository
1. Servo Control
OpenClaw Servo Control Tutorial
Before starting, please complete [01-Peripheral Hardware Configuration], [02-OpenClaw API-KEY Configuration], [03-OpenClaw Model Switching], [04-AI Voice Interaction Configuration], and [05-Three Dialogue Configuration Tests] in the
Preparation Before Usedirectory. If you are only using TUI/WhatsApp, you can skip04. This article assumes the basic environment is ready and only covers servo-related content.
1. Tutorial Objectives
This article demonstrates OpenClaw's natural language control capability through servo peripherals. After completing this tutorial, readers will be able to:
- Understand the basic approach to controlling servos with OpenClaw
- Communicate with OpenClaw via WhatsApp, TUI, and voice commands
- Complete four servo cases: single servo control, servo dancing, yes/no Q&A, ping-pong simulation, and pointer simulation
2. Hardware Preparation
- OpenClaw main control board
- Servo
[1 unit / 4 units] [Optional] Microphone module- Wiring diagram

3. Software Preparation
Code entry points used in this tutorial:
- Low-level driver code: /home/pi/hardware_hal_demo/
- Python driver library: /home/pi/Downloads/python/
- Voice entry:
/home/pi/voice_to_openclaw/src/main.py - Terminal text entry:
/home/pi/voice_to_openclaw/src/text_main.py
4. Testing Servo Control
Before starting this tutorial, please complete an openclaw tui basic conversation self-check first; if you haven't done this yet, see [05-Three Dialogue Configuration Tests]. After confirming OpenClaw can respond normally, proceed with the servo-specific test.
Enter TUI by typing the following in the terminal:
openclaw tui

After ensuring the hardware is properly connected, you can test servo control. Type the following in the terminal:
- Rotate servo 1 to 0 degrees
- Rotate the servo to 90 degrees
- Rotate the servo to 180 degrees
Note: You can specify which servo to control individually

If you can see the servo driving normally, it means the following are all working correctly:
- OpenClaw can receive instructions
- Servo power supply is normal
- Servo angle control range is correct
- Clear feedback can be seen after command execution
5. Three Ways to Communicate with OpenClaw
| Method | Suitable Scenario | Advantages | Suggested Use |
|---|---|---|---|
| Remote control, classroom demonstration | Easy to connect, suitable for multi-person experience | Demonstrate "remote natural language control" | |
| TUI | Local debugging, command verification | Most direct, easiest to troubleshoot | First to get the control link working |
| Voice Code | Voice interaction, complete AI experience | Closest to real conversation experience | As the final demonstration solution |
If you have the optional AI voice module + speaker, the TUI and WhatsApp conversations need to broadcast OpenClaw's replies. You can run the following program in the terminal. This is not needed for AI voice module conversations.
- Modify the TTS enable parameter
xxxxxxxxxx/home/pi/voice_to_openclaw/.env
xxxxxxxxxxENABLE_TTS=true # This parameter controls whether to broadcast replies. After saving, run the program below in the terminal.- Terminal input
xxxxxxxxxxcd ~/voice_to_openclawsource .venv/bin/activatepython -m src.openclaw_session_tts
5.1 WhatsApp Solution
For WhatsApp integration, QR code creation, and gateway restart steps, please refer directly to [05-Three Dialogue Configuration Tests]. This section only includes dialogue examples suitable for the servo tutorial.
You can converse directly, for example:
- Rotate servo 1 to 0 degrees
- Rotate the servo to 90 degrees
- Make the servo swing left and right

5.2 TUI Solution
If you have already completed the TUI self-check from chapter 0, simply type the following command in the terminal to continue the conversation:
xxxxxxxxxxopenclaw tui

5.3 Voice Code Solution
xxxxxxxxxxRequires optional AI voice interaction module + speaker
For voice module installation, environment configuration, and basic wake-up flow, please refer directly to [04-AI Voice Interaction Configuration]. This is most suitable for demonstrating verbal servo commands, for example:
- Rotate the servo to 90 degrees
- Make the servo nod
- Make the servo swing left and right

6. Comprehensive Cases
Note: All demonstrations below use the openclaw tui method for conversation (you can choose your own conversation method)
6.1 Case 1: Servo Dancing
Experiment Objective
Make the servo move continuously through a set of preset angles, forming a "dancing" rhythm effect.
Effect Description
The servo can switch between multiple angles, such as left swing, center, right swing, fast shake, and return to the initial position. Although there is only one servo, through changes in movement rhythm, it can still show a clear sense of "dance".
Example Commands
- Make the servo dance for 10 seconds
- Make the servo swing left and right with a faster rhythm
- Give the servo a three-beat dance step
6.2 Case 2: Yes/No Q&A
Experiment Objective
Have the servo express "yes" or "no" through movements, such as nodding for "yes" and shaking head for "no".
Effect Description
When OpenClaw determines the answer is affirmative, the servo performs a nodding action; when the answer is negative, the servo performs a head-shaking action. This case is very suitable for highlighting the combination of "natural language understanding + movement expression".
Example Commands
- If the answer is "yes", make the servo nod
- If the answer is "no", make the servo shake its head
- Help me judge this question and answer with servo movements
6.3 Case 3: Ping-Pong Simulation
Experiment Objective
Make the servo continuously move left and right, simulating the feeling of a ping-pong ball bouncing back and forth between both sides of the table.
Effect Description
The servo moves evenly or variably between two boundary angles. If accompanied by voice description or screen prompts, the audience can easily understand this as a simulation of "ping-pong ball movement".
Example Commands
- Make the servo simulate ping-pong ball movement back and forth
- Swing left and right 20 times with faster speed
- Starting from the left, do a round-trip movement demonstration
6.4 Case 4: Pointer Simulation
Experiment Objective
Use the servo as a rotatable pointer to indicate values, directions, or status.
Effect Description
This case can very intuitively demonstrate the mapping relationship from "abstract value -> actual angle". For example, mapping values from 0 to 100 to angles from 0 to 180 degrees allows the servo to point to the target position like a dashboard pointer.
Example Commands
- Turn the pointer to 30%
- Have the servo point to the 90-degree position
- Simulate a dashboard with current value at 75