powered by TinkerSpace.in
Join free
TinkerPy Projects lessons
๐Ÿค–
Lesson 9 of 10 ยท Maker ยท 15 min

Drive a robot

Control two motors with robot_control() to drive, turn and stop.

๐Ÿ”Œ Wiring

Connect the motor driver: o3/o4 = right motor, o5/o6 = left motor.

Tell the board which pins are motors in setup. Then robot_control(left, speed, right, speed) drives: "F" forward, "B" backward, "S" stop.

TinkerPy
import motor

setup:
    o3 = set_function(motor_right_forward)
    o4 = set_function(motor_right_backward)
    o5 = set_function(motor_left_forward)
    o6 = set_function(motor_left_backward)

loop:
    robot_control("F", 80, "F", 80)
    wait(1000)
    robot_control("B", 80, "F", 80)
    wait(500)
Forward for 1 second, then spin left for half a second โ€” it draws a square!
๐Ÿ’ก Tip

Left wheel backward + right wheel forward = spin left on the spot.

๐Ÿš€ Your turn

Make the robot drive in a big circle: both forward, but one wheel slower.