Rusty Car-go line follower
A car that follows a light-absorbing black line using Infrared sensors.
Author: Mohamed Daoudo
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-Joan-DwD
Descriptionβ
Rusty Car-go is a car programmed in Rust that follows a black colored tape that absorbs light compared to the surrounding surface which typically absorbs more light using IR (infrared) sensors that read digital low or digital high, and the Rasberry Pi Pico 2W reads these signals and adjusts the motors' speed/direction via L298N moto driver, and lights up a little LED when the car is going. This project serves as a door to building more more creative and fun projects.
Motivationβ
As a little kid, the idea of seeing wires connected to each other causing machines to move and work, whether for fun or to assist us in our daily lives fascinated me. It led me to build simple projects, such as small fans during the summer or a cotton candy machine because I enjoyed sweets. Reminiscing about these days motivated me to work with DC motors and wires again and build a car with them.
Architectureβ
The Raspberry Pi Pico 2W powered by L298N motor driver's onboard 5V regulator to ensure stable supply, It serves as a brain that directs the behaviour of the robot, it's technically responsible for data processing, It outputs directional control and PWM speed signals to the L298N Motor driver which is connected to it via several GPIO pins.
The IR sensors, powered by 3.3V power source of the pico, are connected to the Pico's GPIO pins, detect the line's position based on the color black and send digital signals to the microcontroller to keep the robot on it's track .
The L298N motor driver, powered by batteries, controls the speed and direction of DC motors connected to it via it's output terminals, whose role is to drive the robot's wheels according to Pico's commands, simultaneously, an LED connected to Pico's GPIO pin lights up whenever the motors are active, providing visual feedback.
Finally, the chassis, it provides a well-structured body for the components ensuring stable operation, protection, and ease of assembly.

Logβ
Week 5-11 Mayβ
I started imagining the code and it's structure to make it well-suitable and compatible with what I learned throughout the labs, and wrote a few simple lines regarding the initialization of my components and their behaviour (e.g. PWM for my car's speed via En pins).
However, I immediately started working on the car by assembling and testing some of the components to ensure that they were in a perfect condition as soon as they arrived as it had a higher priority than the software part at that moment.
Moreover, I started desiging an early inchoate version of my KiCad schematic for the robot in order to gain more familiarity with the software and make some improvements later for the Hardware Milestone.
Week 12-18 Mayβ
I finally received all of my stuff including what was missing and used my solderer to connect whats needed (RP, DC motors, and the Switch), assembled all the components, made sure everything is wired and connected carefully, and acquired the final model for the robot.
I also got to update my KiCad schematic and obtain one final version that suits and matches well with my board connections, and took better shots of my hardware.
Without further ado, I began contemplating the software part more deeply and committed what I had written initially.
Week 19-25 Mayβ
This week marked the successful completion of the software for my Car-go. With all hardware components assembled, I focused entirely on finalizing the embedded Rust firmware.
The software is designed to continuously read sensor data in real time and adjust motor behavior accordingly. Depending on the detected position of the black line, the system dynamically regulates motor speed and direction using PWM signals, enabling the car to follow gentle curves and turns smoothly and accurately.
I implemented a responsive control mechanism that interprets various sensor combinations to determine the appropriate motion, such as moving forward, turning left or right, or stopping when the line is lost. All control logic is handled asynchronously to ensure fast reaction times and reliable performance.
After extensive testing and calibration, including adjusting sensor thresholds and motor speeds, the car now tracks the line. With the final version of the code committed and functioning as intended, this week concludes the full integration of software into a working robotic system.
Hardwareβ
- Raspberry Pi Pico 2W: The central controller of the robot aka the "brain".
- Infrared sensors: Used for black or white line detection.
- L298N motor driver: Controls DC motor speed or direction.
- DC motors: Used to move and steer the robot.
- 2 AA battery holders connected (4x, 3x): Power supply to the motor driver.
- LED: Indicator of motor activity.
- I/O Switch: Adds more flexibility in turning off/on the robot instead of manual wiring.
- The robot chassis: It serves as the body of the robot and holds all components.
Picturesβ



Schematicsβ
Bill of Materialsβ
| Device | Usage | Price |
|---|---|---|
| Raspberry Pi Pico 2W | Microcontroller | 39.66β―RON |
| IR sensors | line detection | 10,47β―RON |
| DC motors with wheels & chassis (unassembled) | Structure of the robot | 79.59 RON |
| L298N Motor Driver | Control speed of DC motors | 10.99 RON |
| Male-Male jumper wires set | Connecting components | 7.99 RON |
| 10cm Female-Male jumper wires | Connecting components | 2.99 RON |
| 20cm Female-Male jumper wires | Connecting components | 3.99 RON |
| LED | Motor activity indication | Already had it |
| Switch | Power switching | 1.99 RON |
| Battery holder 4 x R6 | Power supply | 9.43 RON |
| Battery holder 3 x R6 | Power supply | 3.95 RON |
| Breadboard | Circuit building | 4.56 RON |
Softwareβ
| Library | Description | Usage |
|---|---|---|
| defmt | Logging and debugging | printing debug information |
| embassy_executor | Task management system for asynchronous Rust | spawning asynchronous tasks concurrently |
| embassy_rp::gpio | Pico GPIO control pins | configuring digital input/output pins |
| embassy_rp::pwm | Pulse width modulation | to mainly control motor speed and direction |
| embassy_time | Time and delay handling in asynchronous Rust | adds delays or wait for a specific duration in tasks |
| panic_probe | Panic handling | Sends panic messages through defmt |
| embassy_sync::blocking_mutex::raw::ThreadModeRawMutex | blocking thread mutex | Provides safe access to shared data across async tasks |
| embassy_sync::channel | Channel messaging system | Allows async message passing between producers and consumers |
Linksβ
1.How to construct line following robot