Robot Car¶
A small two-wheeled car that drives itself through a corridor track on the floor. An Arduino Uno runs the motors and feels the walls with three distance sensors. A Raspberry Pi with a webcam reads AprilTags taped to the walls, works out where the car is on the track, and tells the Uno where to go.
How it works¶
flowchart LR
CAM[USB webcam] --> PI
subgraph PI[Raspberry Pi 5 · Python]
TAGS[Find tags] --> POSE[Where am I?<br/>x, y, heading]
POSE --> SM[Decide<br/>state machine]
end
SM -- "F 150, T -90, S" --> UNO
subgraph UNO[Arduino Uno · C++]
CMD[Follow commands] --> DRV[TB6612 driver]
WALLS[HC-SR04 front<br/>Sharp IR left and right] --> CMD
end
DRV --> MOT[Two TT motors]
UNO -- "distances" --> SM
The car has two brains, and each does what it's good at.
- The Uno does the fast, physical work: it reads the distance sensors many times a second and keeps the car centered between the walls. It's the same kind of code you wrote for the dispenser.
- The Pi does the slow, thinking work in Python: it looks at camera frames, finds AprilTags, and decides what to do next. It sends the Uno short text commands over the USB cable, like
F 150(forward at speed 150),T -90(turn 90° right) orS(stop). You design those commands.
If the Pi side isn't working on a given day, the Uno still drives the car on its own.
The six classes¶
| Class | By the end, the car… |
|---|---|
| 1 · Drive | drives a square when you type commands into the Serial Monitor. |
| 2 · Feel the walls | drives down a corridor without touching the walls and stops before the end wall. |
| 3 · The Pi takes over | is driven from a laptop across the room while you watch its camera. |
| 4 · See tags | turns to face an AprilTag and stops 20 cm from it. |
| 5 · Know where it is | shows its position live on a map of the track and goes to tag 3, then tag 7, on command. |
| 6 · Showcase | navigates the track to a goal a visitor picks. |
Before Class 1¶
- Flash the Pi's microSD card. Use Raspberry Pi Imager on a laptop to put Raspberry Pi OS (64-bit) on the card. In the settings screen, set a hostname (for example
robotcar), a username and password, the Wi-Fi network Dr. Alvear gives you, and turn on SSH. You won't need the Pi until Class 3, but this takes a while. - Cut the track walls. Foam board strips about 15 cm tall. You'll need a straight corridor for Class 2 (about 1 m long, one car-width plus 10 cm wide) and the full 2 × 2 m track by Class 5.
- Check PlatformIO. Make sure a new Uno project still builds and uploads on your laptop.
Where Claude Code fits¶
This is one of the projects where Claude Code is allowed, for specific parts. It's there for the math and plumbing that would take weeks to learn on their own, so you can spend your time on the car.
| Claude Code may help with | Yours to write |
|---|---|
| Camera calibration (Class 4) | All the Arduino code: motors, sensors, commands |
| Turning a tag's pose into the car's (x, y, heading) (Class 5) | Wall following and the proportional controller |
| The Python side of the Serial bridge (Class 3) | The command set the Pi and the Uno share |
| The live top-down plot (Class 5) | The car's decisions: the Python state machine |
When Claude Code writes something for you, read it, run it, and be ready to say what it does. Put a comment at the top of each file it helped with.
Credits¶
- AprilTags were developed by the APRIL Robotics Lab at the University of Michigan. You'll use the
pupil-apriltagsPython package to read them. - OpenCV does the camera work. Name both on your poster.