MechBase Line Following Rover

Project 1 — DIY Mechatronics Educational Kit
Technic-compatible chassis • Pi Zero 2 W • IR Sensor Array
Generated: 2026-06-01

OVERVIEW

This is your first project in the MechBase mechatronics curriculum. You'll build a 2WD robot chassis from Technic-compatible parts, mount sensors and electronics, and program it to follow a black line.

Finished dimensions: 220mm × 140mm × 75mm (L × W × H)
Wheelbase: 120mm | Track width: 140mm
Drive: 2× TT Micro Motor (37mm, ~120 RPM at output shaft)
Electronics: Raspberry Pi Zero 2 W + Adafruit Dual Motor HAT
Sensors: 3× TCRT5000 IR reflectance array

What you'll learn: Mechanical assembly → Sensor integration → PID control → Closed-loop automation

PARTS LIST

Sort your parts before building. Verify each part number against your physical inventory.

CHASSIS PARTS

13811Baseplate 32×32
22730Technic Brick 1×10 with Holes (10 holes, 80mm)
43701Technic Brick 1×4 with Holes (4 holes, 24mm)
42780Technic Pin with Short Friction Ridges (8mm)
13737Technic Axle 10L — rear drive axle
132073Technic Axle 5L — front caster axle
44265cTechnic Bush ½ Smooth — wheel spacers
456908Technic Wheel 43.2mm (with tire mounted)
23894Technic Brick 1×6 with Holes — motor mounts
73024Brick 2×4 — Pi mount + battery mount

ELECTRONICS

2TT-Motor37mm Micro Gear Motor (3mm output shaft, 3-6V DC)
1Adafruit Dual Motor HATI2C motor driver for Pi Zero 2 W
1Pi Zero 2 WMain controller (512MB RAM, GPIO, WiFi/BT)
3TCRT5000IR reflectance sensor (line following)
12S LiPo 7.4V 2200mAhMotor power supply
12S LiPo ChargerSafe charging (1A recommended)
1Breadboard + Jumper KitPrototyping and sensor wiring
Part 56908 is sold as a combined wheel+tire assembly. The racing tire is already mounted — do not add separate tires.

BUILD INSTRUCTIONS

Step 1: Baseplate

Set down the 32×32 baseplate on your work surface. Orient it so the longer side runs left to right in front of you.

Baseplate is flat and stable on your work surface.

Step 2: Main Frame Rails

Take two 2730 bricks (1×10 with holes). These form the two parallel rails of the chassis frame.

Rear rail: Place one brick horizontally near the rear third of the baseplate. The Technic holes should face upward.

Front rail: Place the second brick parallel to the first, about 8 studs (64mm) forward. The two rails should be evenly spaced.

Press both bricks firmly onto the baseplate studs.

Mechatronics concept: Parallel rails create a rigid track for axle mounting. The hole spacing (8mm center-to-center) determines your wheel track width.
Two parallel rails, each 10 studs long, about 8 studs apart, both centered left-to-right on the baseplate. Holes facing up.

Step 3: Cross Braces

Take two 3701 bricks (1×4 with holes). These connect the rails at each end, forming a rigid rectangular frame.

Rear cross brace: Place one brick perpendicular to the long rails at the rear end.

Front cross brace: Place the second brick the same way at the front end.

Insert 2780 pins at each corner. Push each pin down through the overlapping Technic holes. Use 4 pins total.

Mechatronics concept: Cross braces transfer lateral loads between rails, preventing racking. The friction pins create a semi-permanent joint.
Rectangular frame: two parallel rails connected at both ends by cross braces. All 4 corners locked with pins.

Step 4: Axle Mount Brackets

Take four 3701 bricks (1×4 with holes). These form the axle mount brackets that extend outward from each rail.

Rear mounts (2 bricks): At each end of the rear cross brace, place a 3701 extending outward from the frame edge.

Front mounts (2 bricks): Repeat at the front cross brace.

Lock each with a 2780 pin through the overlapping hole. Use 4 pins total.

Four 1×4 mount bricks extending outward from the frame. Mounts are symmetrical left-to-right.

Step 5: Rear Drive Axle

Take the 3737 axle (10L, 8mm diameter, ~80mm long).

Slide the axle horizontally through the rear axle mount brackets. Center it so it extends about 8mm past each mount bracket for wheel clearance.

Lock in place: Insert 32062 (2L Notched) axles into adjacent holes on each side. Notch faces UP to prevent axle from sliding out.

Mechatronics concept: The axle is the rotation axis for the wheels. The 8mm diameter is standard for Technic.
Rear axle rotates freely. Axle does not slide in or out. Notched 2L axles lock it in place laterally.

Step 6: Front Caster Axle

Take the 32073 axle (5L, 8mm diameter, ~40mm long). Shorter than rear — intentional since front is passive.

Slide through front axle mount brackets. Lock with two 32062 (2L Notched) axles, notches facing UP.

Front axle rotates freely. Neither axle can be pushed in or out by hand.

Step 7: Wheel Installation

On each axle end: slide a 4265c (Bush ½ Smooth) onto the axle first as spacer, then press the 56908 wheel onto the axle past the bushing.

Repeat for all 4 wheels. Order: bushing → wheel

Part 56908 already includes its racing tire. Do not add separate tires.
All 4 wheels mounted. Each wheel spins freely. Wheels do not touch the frame or each other.

Step 8: Motor Mount Brackets

Take two 3894 bricks (1×6 with holes). These provide motor mounting positions alongside the rear axle.

Place each brick parallel to the long rails, positioned just outside the rear axle mounts.

Lock each with a 2780 pin where it overlaps the long rail.

Two 1×6 motor mount brackets positioned alongside the rear section of each rail. Locked with pins.

Step 9: Mount Motors

Each TT Micro Motor (37mm):

Mounting: Position each motor so its output shaft aligns with the rear axle. Use the Adafruit TT motor coupler (product 3810) to connect the 3mm motor shaft to the 8mm Technic axle. Secure with zip ties to the 3894 brackets.

Mechatronics concept: Motors are the actuators that convert electrical energy to mechanical rotation. The coupler adapts the motor's small output shaft to the larger chassis axle.
Both TT motors secured. Motor shafts coupled to rear axle. Motors firmly mounted and do not wobble.

Step 10: Electronics Platform

Build a raised platform in the center of the chassis using four 3024 bricks (2×4) stacked for airflow underneath.

Use zip ties to secure the Pi Zero 2 W to the platform. The Adafruit Dual Motor HAT stacks directly on top of the Pi's GPIO header.

Mechatronics concept: The Pi is the controller — it runs the decision logic that reads sensors and controls motors. Raised mounting allows heat dissipation.
Pi Zero 2 W secured to raised platform. Adafruit HAT stacked on Pi. Platform allows airflow underneath.

Step 11: IR Sensor Array Mount

Take three 3701 bricks (1×4 with holes). These form the front mount for the IR sensor array.

Place them side-by-side at the front of the chassis, extending forward past the front axle. This positions the sensors to look at the ground ahead.

Mount the three TCRT5000 IR sensors on a breadboard, then attach the breadboard to the Technic brackets using zip ties. Sensors should face downward, ~10mm above the ground.

Mechatronics concept: The IR array is the perception system. Each sensor emits IR light and measures reflectance — black line absorbs IR (low reading), white surface reflects IR (high reading).
IR sensor array mounted at front of chassis, facing downward. Sensors ~10mm above ground. Three sensors evenly spaced left-center-right.

Step 12: Battery Mount

Take one 3024 brick (2×4). Place it at the rear of the chassis as a battery anchor point.

Secure the 2S LiPo 7.4V 2200mAh battery in the rear corner, away from spinning wheels. Use velcro straps or zip ties.

Power routing:

Mechatronics concept: Power management. Motors cause voltage dips that can crash the Pi. Separate motor power from logic power. Common ground is essential.
Battery secured at rear. Power wires routed along frame rails. Common ground established.

WIRING DIAGRAM

        FRONT
    +-------------------+
    |  IR Array  IR     |  <- Perception (sensors)
    |  +--+--+--+       |
    |  |L |C |R |       |  L=Left, C=Center, R=Right
    |  +--+--+--+       |
    |                   |
    |   +-------------+ |  <- Controller (Pi + HAT)
    |   | Pi Zero 2 W | |
    |   | + Motor HAT | |
    |   +-------------+ |
    |                   |
    |  +------+ +------+|  <- Actuators (motors)
    |  |  M1  | |  M2  ||
    |  +------+ +------+|
    |                   |
    |   +-------------+ |  <- Power (2S LiPo)
    |   |  Battery    | |
    |   +-------------+ |
    +-------------------+
        REAR

IR SENSOR WIRING

PinColorConnect to
VCCRed3.3V (Pi GPIO)
GNDBlackGND
DO (Digital)YellowGPIO 17 (Left), GPIO 27 (Center), GPIO 22 (Right)
AO (Analog)WhiteNot used (digital mode)

MOTOR WIRING

Connect motors to Adafruit Dual Motor HAT terminals:

SOFTWARE

1. Install dependencies

sudo apt update
sudo apt install -y python3-pip
pip3 install adafruit-circuitpython-motorkeeper adafruit-blinka

2. Create project folder

mkdir ~/mechbase && cd ~/mechbase

3. Save line_follower.py

import time
import board
import busio
import digitalio
from adafruit_motor import stepper

# Initialize I2C and motor HAT
i2c = busio.I2C(board.SCL, board.SDA)
motor_hat = stepper.MotorHAT(i2c)

# Motor setup
left_motor = motor_hat.motor1
right_motor = motor_hat.motor2

# IR sensors (digital mode)
ir_left = digitalio.DigitalInOut(board.D17)
ir_center = digitalio.DigitalInOut(board.D27)
ir_right = digitalio.DigitalInOut(board.D22)

def read_sensors():
    # Read IR sensor array, return list of boolean values
    return [
        not ir_left.value,
        not ir_center.value,
        not ir_right.value
    ]

def follow_line():
    sensors = read_sensors()
    
    if sensors[1]:  # Center on line
        left_motor.throttle = 0.5
        right_motor.throttle = 0.5
    elif sensors[0]:  # Line on left, turn left
        left_motor.throttle = 0.3
        right_motor.throttle = 0.5
    elif sensors[2]:  # Line on right, turn right
        left_motor.throttle = 0.5
        right_motor.throttle = 0.3
    else:  # Lost line, stop
        left_motor.throttle = 0
        right_motor.throttle = 0

# Main loop
print("Line Following Rover - Starting")
try:
    while True:
        follow_line()
        time.sleep(0.05)
except KeyboardInterrupt:
    print("Stopping")
    left_motor.throttle = 0
    right_motor.throttle = 0

4. Run it

python3 line_follower.py

MECHATRONICS CONCEPTS COVERED

ConceptWhat You BuiltReal-World Application
Sensors → PerceptionIR array detects black lineAutonomous vehicles, industrial inspection
Actuators → MotionDC motors drive wheelsRobotics, conveyor systems, CNC machines
Controller → Decision LogicPi runs sensor→motor loopPLC programming, embedded systems
Power ManagementSeparate motor/logic powerAny electromechanical system
Closed-Loop ControlRead sensor → adjust motorsPID controllers, automation systems

TROUBLESHOOTING

SymptomCheckFix
Wheels don't turnMotor wires connected to correct HAT terminalsVerify M1/M2 wiring
Robot spins in circleMotor directionSwap motor wires on one side
IR sensors not detecting lineSensor height (~10mm)Adjust bracket position
Pi crashes under loadPower supplyUse buck converter for Pi 5V rail
Line following too jerkySensor response timeAdjust sleep time in code (0.05 → 0.02)

NEXT PROJECTS

Once this is working, you can expand:

  1. Project 2: Add obstacle avoidance (HC-SR04 ultrasonic on servo turret)
  2. Project 3: Add camera tracking (Pi Camera v2, follow colored object)
  3. Project 4: Multi-robot coordination (two rovers communicating)
  4. Project 5: SLAM mapping (LiDAR, room mapping, navigation)

APPENDIX: PART VERIFICATION

All parts verified against LDraw library and BrickLink catalog (2026-06-01).

Technic Part Compatibility

Adafruit TT Motor Coupler

The Adafruit TT motor coupler (product 3810) converts the 3mm hex motor shaft to standard 8mm Technic axle. This is the mechanically correct solution for connecting TT motors to Technic axles.

MechBase Line Following Rover v1.0
© 2026 MechBase Educational Kits
Technic-compatible parts • Pi Zero 2 W • Open-source firmware