Wheels and drivetrains
What you’ll learn
- How wheel size affects speed and distance
- How a two-wheeled robot steers (differential drive)
- Other drivetrains: casters, tracks, omni and mecanum wheels
Wheel size
Each turn of a wheel moves the robot one circumference:
Distance per turn = π × diameter
A 65 mm wheel (common in kits) moves about 3.14 × 65 ≈ 204 mm per turn. Bigger wheels go further per turn (faster), but need more torque to start and climb.
Differential drive
Most beginner robots have two driven wheels and a free caster wheel or ball for balance. They steer by changing the speeds of the two wheels:
| Left wheel | Right wheel | Robot |
|---|---|---|
| Forward | Forward (same speed) | Straight |
| Forward fast | Forward slow | Curves right |
| Forward | Stopped | Pivots around the right wheel |
| Forward | Backward | Spins on the spot |
| Backward | Backward | Reverses |
This is exactly what motors(left, right) does in the robot simulator.
Other drivetrains
| Drivetrain | Pros | Cons |
|---|---|---|
| 2 wheels + caster | Simple, cheap, turns on the spot | Caster can catch on bumps |
| 4-wheel skid steer | More grip and pushing power | Wheels scrub when turning |
| Tracks | Grip on rough ground and sand | Slow, lose energy to friction |
| Omni / mecanum | Can drive sideways | Expensive, less grip |
| Car-style steering | Efficient at speed | Can’t turn on the spot |
Example: how fast is my robot?
A gear motor turns at 200 rpm with 65 mm wheels. Speed = 200 × 0.204 m per minute = 40.8 m/min ≈ 0.68 m/s.
Example: driving a set distance
To drive 1 m with 65 mm wheels: 1000 ÷ 204 ≈ 4.9 wheel turns. With wheel encoders counting 20 slots per turn, that’s about 98 counts.
Example: steering in code
motors(60, 60); // straightmotors(60, 30); // gentle right curvemotors(60, -60); // spin right on the spotmotors(-40, -40); // reverseTry it
Write different motors(left, right) values and watch the path in the obstacle room.
Robot commands
motors(left, right): wheel power, −100 to 100lineLeft(),lineRight():trueover the black linedistance(): cm to the nearest thing ahead (max 200)distanceLeft(),distanceRight(): cm to the sideslinePosition(): where the line is, −1 (left) to 1 (right), ornullmillis(): milliseconds since Runprint(value): show a message belowsetup()runs once;loop()runs 50 times a second
CirclesEasy
Make the robot drive in a big circle, then a small circle.
Big circle: motors(60, 45). Small circle: motors(60, 10). The bigger the speed difference, the tighter the turn.
Square danceMedium
Drive forward for 1 s, spin about 90° to the right, and repeat.
Use millis() % 1600 to split time into a “drive” part and a “turn” part. Adjust the turn time until it’s close to 90°.
Show an answer
function loop() { const t = millis() % 1600; if (t < 1000) motors(50, 50); // drive for 1 s else motors(50, -50); // turn for 0.6 s}Open-loop turns drift, which is why real robots use encoders or a gyro to measure the angle.
Wheel mathsHard
Your robot has 80 mm wheels on 150 rpm motors. How long does it take to drive 3 m? Circumference = π × 80 ≈ 251 mm. Speed = 150 × 0.251 ≈ 37.7 m/min ≈ 0.63 m/s. 3 ÷ 0.63 ≈ 4.8 s.
Quick check
Finished this lesson?