Project 1 — DIY Mechatronics Educational Kit
Technic-compatible chassis • Pi Zero 2 W • IR Sensor Array
Generated: 2026-06-01
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
Sort your parts before building. Verify each part number against your physical inventory.
| 1 | 3811 | Baseplate 32×32 |
| 2 | 2730 | Technic Brick 1×10 with Holes (10 holes, 80mm) |
| 4 | 3701 | Technic Brick 1×4 with Holes (4 holes, 24mm) |
| 4 | 2780 | Technic Pin with Short Friction Ridges (8mm) |
| 1 | 3737 | Technic Axle 10L — rear drive axle |
| 1 | 32073 | Technic Axle 5L — front caster axle |
| 4 | 4265c | Technic Bush ½ Smooth — wheel spacers |
| 4 | 56908 | Technic Wheel 43.2mm (with tire mounted) |
| 2 | 3894 | Technic Brick 1×6 with Holes — motor mounts |
| 7 | 3024 | Brick 2×4 — Pi mount + battery mount |
| 2 | TT-Motor | 37mm Micro Gear Motor (3mm output shaft, 3-6V DC) |
| 1 | Adafruit Dual Motor HAT | I2C motor driver for Pi Zero 2 W |
| 1 | Pi Zero 2 W | Main controller (512MB RAM, GPIO, WiFi/BT) |
| 3 | TCRT5000 | IR reflectance sensor (line following) |
| 1 | 2S LiPo 7.4V 2200mAh | Motor power supply |
| 1 | 2S LiPo Charger | Safe charging (1A recommended) |
| 1 | Breadboard + Jumper Kit | Prototyping and sensor wiring |
Set down the 32×32 baseplate on your work surface. Orient it so the longer side runs left to right in front of you.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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:
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
| Pin | Color | Connect to |
|---|---|---|
| VCC | Red | 3.3V (Pi GPIO) |
| GND | Black | GND |
| DO (Digital) | Yellow | GPIO 17 (Left), GPIO 27 (Center), GPIO 22 (Right) |
| AO (Analog) | White | Not used (digital mode) |
Connect motors to Adafruit Dual Motor HAT terminals:
sudo apt update sudo apt install -y python3-pip pip3 install adafruit-circuitpython-motorkeeper adafruit-blinka
mkdir ~/mechbase && cd ~/mechbase
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
python3 line_follower.py
| Concept | What You Built | Real-World Application |
|---|---|---|
| Sensors → Perception | IR array detects black line | Autonomous vehicles, industrial inspection |
| Actuators → Motion | DC motors drive wheels | Robotics, conveyor systems, CNC machines |
| Controller → Decision Logic | Pi runs sensor→motor loop | PLC programming, embedded systems |
| Power Management | Separate motor/logic power | Any electromechanical system |
| Closed-Loop Control | Read sensor → adjust motors | PID controllers, automation systems |
| Symptom | Check | Fix |
|---|---|---|
| Wheels don't turn | Motor wires connected to correct HAT terminals | Verify M1/M2 wiring |
| Robot spins in circle | Motor direction | Swap motor wires on one side |
| IR sensors not detecting line | Sensor height (~10mm) | Adjust bracket position |
| Pi crashes under load | Power supply | Use buck converter for Pi 5V rail |
| Line following too jerky | Sensor response time | Adjust sleep time in code (0.05 → 0.02) |
Once this is working, you can expand:
All parts verified against LDraw library and BrickLink catalog (2026-06-01).
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.