By Kevin McAleer, 5 Minutes
Page last updated November 24, 2026

This is one of the best features of a bus servo. Switch the torque off and the servo goes limp, but it still reports its position. So you can pose a robot with your hands, record where every joint is, and play it back later. Teaching by demonstration, with no maths and no guessing.
Three steps:
flowchart LR
A["Torque off"] --> B["Move by hand"]
B --> C["Read positions into a list"]
C --> B
C --> D["Torque on"]
D --> E["Play the list back"]
The torque calls from the blog are the whole trick:
bus.set_torque(1, False) # go limp, free to move by hand
pos, _ = bus.read_pos_speed(1)
print("Recorded position:", pos)
bus.set_torque(1, True) # re-energise
When you switch torque back on, you want the servo to hold where it is, not lunge somewhere. So the program first sends each servo a move() to its current position, and only then enables torque. It’s one extra write per servo and it means the target matches reality.
A pose is a list of positions, one per servo in SERVO_IDS. The program records a few poses, saves them to a file called poses.json so they survive a reboot, then plays them back. Change SERVO_IDS to match your chain.
import json
import time
from sts3215 import STS3215 # sts3215.py from the repo
SERVO_IDS = [1, 2] # the servos in your chain
POSE_FILE = "poses.json"
PLAY_SPEED = 600 # position steps per second
PLAY_ACC = 30
REPEATS = 3
SETTLE_MS = 300 # pause at each pose
bus = STS3215(uart_id=0, tx_pin=0, rx_pin=1, baudrate=1_000_000)
def read_pose():
"""Return a list of positions, one per servo, or None if any is missing."""
pose = []
for servo_id in SERVO_IDS:
position = bus.read_position(servo_id)
if position is None:
return None
pose.append(position)
return pose
def go_limp():
for servo_id in SERVO_IDS:
bus.set_torque(servo_id, False)
def hold_here():
"""Aim every servo at where it is now, then switch torque on."""
pose = read_pose()
if pose is None:
print("Can't read every servo, so torque stays off")
return False
for servo_id, position in zip(SERVO_IDS, pose):
bus.move(servo_id, position, speed=PLAY_SPEED, acc=PLAY_ACC)
for servo_id in SERVO_IDS:
bus.set_torque(servo_id, True)
return True
def wait_until_stopped(timeout_ms=5000):
start = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), start) < timeout_ms:
if all(bus.read_moving(s) == 0 for s in SERVO_IDS):
return
time.sleep_ms(50)
def record():
count = int(input("How many poses will you record? "))
poses = []
go_limp()
for n in range(count):
input("Pose {}: move the servos by hand, then press ENTER ".format(n + 1))
pose = read_pose()
if pose is None:
print(" No reading, so that pose was skipped")
continue
poses.append(pose)
print(" Saved", pose)
return poses
def save_poses(poses):
with open(POSE_FILE, "w") as f:
json.dump(poses, f)
def load_poses():
try:
with open(POSE_FILE) as f:
return json.load(f)
except (OSError, ValueError):
return []
def play(poses):
if not poses or not hold_here():
print("Nothing to play")
return
for lap in range(REPEATS):
print("Lap", lap + 1, "of", REPEATS)
for pose in poses:
for servo_id, position in zip(SERVO_IDS, pose):
bus.move(servo_id, position, speed=PLAY_SPEED, acc=PLAY_ACC)
time.sleep_ms(100) # let the servos start before we ask
wait_until_stopped()
time.sleep_ms(SETTLE_MS)
go_limp()
print("Done. Torque off")
answer = input("Record a new sequence? (y/n) ")
poses = load_poses()
if answer.strip().lower() == "y" or not poses:
poses = record()
save_poses(poses)
play(poses)
Run it, answer y, and the servos go limp. Move them to a pose, press ENTER in Thonny’s shell, move them to the next pose, and so on. Then watch your arm go through the moves on its own, three times.
Each pose moves every servo with the same speed, so a servo with a short way to go arrives first and has to wait for the others. It looks a little robotic. Lesson 11 fixes that by scaling each joint’s speed so they all arrive together.
Common mistakes:
poses.json on the Pico and look at the numbers. Each inner list is one pose.try and except KeyboardInterrupt block.Problem: Can't read every servo, so torque stays off.
Solution: Run the scan from lesson 5 and check every ID in SERVO_IDS answers.
Why: The program won’t switch torque on blind, because it can’t aim the servo at where it is.
Problem: Playback runs, but poses are skipped or wrong.
Solution: Delete poses.json, answer y and record again.
Why: An old file recorded with different servos has the wrong number of positions in each pose.
Comments