Every inventor began with one small project. Pick one and bring your idea to life today!
Great inventors and great teachers all started with one small step. Take yours today!
The same kits we use in 40+ school labs — grab yours and build something you’re proud of.
Log in to continue
TinkerPy has 13 servo functions and 3 robot functions. With them a servo can open a gate with one press, sweep like a radar all by itself, or copy another servo — and a robot car can drive, spin, curve and dance.
A motor that turns to an exact angle from 0° to 180° and holds it. Pick Servo in Circuit Connections: gate = set_output(servo, 0) also sets its start angle.
Each new press moves the servo the other way: start → end, then end → start. Holding the button does not move it again.
Starts a servo sweeping back and forth forever, on its own — even while the rest of the code is busy or waiting.
Drives both wheels in one line: robot_control(left dir, left speed, right dir, right speed). Directions: "F", "B", "S" stop, "X" leave alone.
Drives just one wheel: motor_control_right("F", 70).
Drag the slider to choose an angle and watch the servo arm and the code change.
Tap the buttons to drive around the floor. See which robot_control() line makes each move.
# Add the libraries you need import servo # Give your pins easy-to-remember names i1 = set_name("button") o1 = set_name("gate") o2 = set_name("open_led") # ===== Automatic gate ===== # This code block executes only once setup: button = set_input(push_button, active_low) gate = set_output(servo, 0) open_led = set_output(led) # This code block executes forever loop: if button == ON: # when button is ON servo_flip(gate, 0, 90, 5, 20) # 1st press opens, 2nd press closes if servo_read_angle(gate) > 45: # when servo_read_angle(gate) > 45 open_led = ON # turn open_led ON else: # otherwise open_led = OFF # turn open_led OFF
An automatic gate with servo_flip: the first press of button opens the gate (0° → 90°), the next press closes it. servo_read_angle(gate) tells the program where the gate is, so open_led glows while it is more than half open. The start angle 0 is in set_output(servo, 0).
# Add the libraries you need import servo # Give your pins easy-to-remember names i1 = set_name("up_button") i2 = set_name("down_button") o1 = set_name("arm") # ===== Crane arm ===== # This code block executes only once setup: up_button = set_input(push_button, active_low) down_button = set_input(push_button, active_low) arm = set_output(servo, 90) servo_increment_till(arm, 90, 180, 5, 20) # wake-up stretch: 90° up to 180° servo_decrement_till(arm, 180, 0, 5, 20) # then all the way down to 0° servo_write_angle(arm, 90) # back to the middle # This code block executes forever loop: if up_button == ON: # when up_button is ON servo_increment(arm, 10, 170, 100) # up 10°, never past 170° elif down_button == ON: # otherwise, when down_button is ON servo_decrement(arm, 10, 10, 100) # down 10°, never below 10° wait(100) # pause here for 100 milliseconds before continuing
A crane arm. At start-up it stretches up with servo_increment_till, down with servo_decrement_till and returns to the middle with servo_write_angle. Then two buttons nudge it up and down 10° at a time — never past 170° or below 10°.
# Add the libraries you need import ultrasonic import servo # Give your pins easy-to-remember names o1 = set_name("dish") o2 = set_name("dish2") o5 = set_name("alert") # ===== Twin radar scanner ===== # This code block executes only once setup: i3 = set_input(ultrasonic_trig) # cannot be changed i4 = set_input(ultrasonic_echo) # cannot be changed dish = set_output(servo, 90) dish2 = set_output(servo, 90) alert = set_output(led) servo_sync(dish, dish2) # dish2 copies every move of dish servo_scan_on(dish, 0, 180, 5, 30) # keep sweeping on its own # This code block executes forever loop: d = distance() # -1 when nothing is in range if d > 0 and d < 20: # when d > 0 and d < 20 servo_scan_stop(dish) # freeze, pointing at the object alert = ON # turn alert ON else: # otherwise servo_scan_resume(dish) # carry on from the same place alert = OFF # turn alert OFF
Twin radar dishes (TinkerPy Mega: the ultrasonic uses i3 and i4). servo_scan_on keeps dish sweeping on its own and servo_sync makes dish2 copy it. When something is closer than 20 cm the scan freezes and alert lights; when it goes away the scan resumes from the same place.
# Add the libraries you need import motor import servo # Give your pins easy-to-remember names o1 = set_name("left_arm") o2 = set_name("right_arm") # ===== Robot dance routine ===== # This code block executes only once setup: o3 = set_output(right_motor_P) o4 = set_output(right_motor_N) o5 = set_output(left_motor_P) o6 = set_output(left_motor_N) left_arm = set_output(servo, 90) right_arm = set_output(servo, 90) servo_sync_reverse(left_arm, right_arm) # arms always mirror each other # This code block executes forever loop: robot_control("F", 70, "F", 70) # forward wait(1000) # pause here for 1000 milliseconds before continuing robot_control("B", 70, "F", 70) # spin left wait(600) # pause here for 600 milliseconds before continuing robot_control("F", 40, "F", 90) # curve left wait(1000) # pause here for 1000 milliseconds before continuing robot_control("S", 0, "S", 0) # stop and wave servo_oscillate(left_arm, 90, 30, 150, 5, 15) # oscillate left_arm from angle 30 to 150, start and stop pos: angle 90 motor_control_right("F", 70) # only the right wheel: pivot left wait(700) # pause here for 700 milliseconds before continuing motor_control_right("S", 0) # stop the right wheel motor_control_left("B", 70) # only the left wheel, backwards wait(700) # pause here for 700 milliseconds before continuing motor_control_left("S", 0) # stop the left wheel
A robot dance routine: forward, spin left, curve left, stop and wave, then pivot on one wheel and the other. servo_sync_reverse makes right_arm mirror left_arm while it oscillates. Tune the wait times on your own floor.
A toll-plaza barrier lifts and drops between two angles — a job made for servo_flip.
Airport and weather radars sweep round and round while computers watch the echoes — servo_scan_on does a small version.
Tanks and many robots turn on the spot by running one side forward and the other backward — exactly robot_control("B", 70, "F", 70).
Build a cardboard school gate on a servo. Use servo_flip with a button, and add an LED that shows when the gate is open using servo_read_angle.
🧰 You need: TinkerPy board, servo, push button, LED, cardboardProgram your robot car to dance to a song: forward, spin left, spin right, curve, stop — repeat it 3 times. Add two servo arms with servo_sync_reverse that wave at the end.
🧰 You need: TinkerPy robot car kit (motors on o3–o6), 2 servosMars rovers are driven by motors and turn their cameras and arms with joints controlled by code that is sent all the way from Earth.
5 quick questions to check yourself — free with your TinkerPy account.
Log in