Pi Car
A Raspberry Pi 3 car with several driving modes: it follows a line, avoids obstacles, stops at a table’s edge, has a simple follow mode, and drives from the keyboard or from a panel with its camera’s live video.
What it shows
- Driving modes
- Line following with IR sensors, obstacle avoidance with an ultrasonic sensor on a servo, an edge stop and a follow mode
- Live video control
- A window with the camera’s live video and four arrow buttons, used through VNC from a phone or a laptop
- Hardware from Python
- Motors, three servos, the ultrasonic and IR sensors and a buzzer, all on the Raspberry Pi’s GPIO pins
- A solo build
- From a wooden chassis on 18 April 2022 to clear acrylic by 4 May, built and coded by me
Built · Apr – Jun 2022
A Raspberry Pi on wheels
Four geared motors carry a clear acrylic body, with a Raspberry Pi 3 on top. At the front, the camera looks around on two servos and an ultrasonic sensor turns on a third; under the nose, an IR board watches the floor.
In video
Short silent clips. Tap one to play it.
On the desk and the track
May 2022
Following a tape line on the floor with its IR sensors
May 2022
Stopping at the edge of the desk when its IR sensors lose the floor, and driving on when it is moved back
May 2022
Driven from the camera panel on a laptop, with the car’s live video on the screen
May 2022
A walk around the car on the desk, just rebuilt on clear acrylic
Upright
May 2022
The follow mode: it drives forward while something is within 15 cm
May 2022
The same line, filmed from above
The build
18 Apr 2022
The first build taking shape: a Raspberry Pi 3 and a breadboard on a wooden chassis.
18 Apr 2022
Up close: the Pi, the camera on two servos and the wiring.
18 Apr 2022
The same night, from the side: four geared motors, the battery pack and the Pi on the top deck.
4 May 2022
Rebuilt on clear acrylic, its camera up.
6 May 2022
In the dark, its five-sensor line board lit red at the front.
29 Jun 2022
Me with the car in the ICT lab at Comilla University, its program on the monitor.
How it works
One Pi, a program per mode
Everything runs on the Raspberry Pi, in Python. Each mode is its own program: two read the IR sensors, two the ultrasonic sensor, one drives from the keyboard, and the panel shows the camera with arrow buttons.
Datasheet
- Brain
- A Raspberry Pi 3; Python with RPi.GPIO, gpiozero, OpenCV, Tkinter and pygame
- Drive
- Four geared DC motors on a motor driver
- Servos
- Three: two point the camera, one turns the ultrasonic sensor
- Senses
- The Pi camera, an HC-SR04 ultrasonic sensor, and a five-sensor IR board, of which the code reads three
- Also
- A buzzer
- Body
- Clear acrylic since May 2022; a wooden chassis before it
Driving modes
- Line
- Follows a tape line with three IR sensors
- Obstacles
- Avoids obstacles with the ultrasonic sensor, which a servo turns to look around
- Edge stop
- Stops when its IR sensors lose the floor at a table’s edge
- Follow
- Drives forward while something is within 15 cm of the ultrasonic sensor
- Keyboard
- W and S set the speed, A and D steer, Q stops
- Panel
- A window with the camera’s live video and four arrow buttons; used from a phone or a laptop through VNC
My part
Built alone, at Comilla University
Pi Car was my university project at Comilla University. I built and coded it alone, mostly in the ICT department’s lab. Two parts of the code follow published examples.
Built on
- Ultrasonic sensor
- Tutorials for Raspberry Pi: Using a Raspberry Pi distance sensor
- Keyboard driving
- Ingmar Stapel’s RobotControl.py and L298NHBridge.py
Both are credited in the car’s repository too.
The code
Read the code
Every mode is in its repository, with its pin map and how to run each mode on a Raspberry Pi.
Next: OrbiBot
At Orbitax, I build OrbiBot in my free time. V1 was a mecanum robot with my own firmware, ROS 2 navigation and an AI agent.