Powered by TinkerSpace
Join free
TinkerPy Projects lessons
🦾
Lesson 7 of 10 · Explorer · 12 min

Move a servo

Turn a servo motor to any angle from 0° to 180°.

🔌 Wiring

Connect a servo motor to output o1.

Add import servo at the top to use servo functions. servo_write_angle(o1, 90) points the servo to 90° — straight up.

TinkerPy
import servo

setup:
    o1 = set_function(servo)
    servo_write_angle(o1, 90)
    wait(1000)

loop:
    servo_oscillate(o1, 90, 0, 180, 5, 20)
Starts in the middle, then sweeps from 0° to 180° and back.
💡 Tip

The last two numbers of servo_oscillate are the step size and the delay. Smaller step or bigger delay = slower, smoother sweep.

🚀 Your turn

Make a waving hand: sweep only between 60° and 120°.