Line Follower
A line-following robot built on a Freenove 4WD Raspberry Pi car. Three infrared sensors read the track underneath the chassis and the motors steer to keep the middle sensor over the line.
Hardware Freenove 4WD Raspberry Pi car chassis Raspberry Pi Three downward-facing infrared line sensors (left, center, right) Four DC motors driven through the motor controller board
0 1 0 Centered Drive straight 1 1 0 Drifting right Turn left 0 1 1 Drifting left Turn right 1 0 0 Off to right Sharp left 0 0 1 Off to left Sharp right 0 0 0 Line lost Stop or search 1 1 1 Intersection Drive straight
The main loop reads the sensors tells left and right motor speeds to the motor controller. Turns are made by slowing and strafing one side rather than reversing it, which keeps the correction smooth.
Code layout
Everything lives under FreenovePiCar/Code/Server:
Infrared, reads the three line sensors MotorController, sets speed and direction for the four motors
Press Ctrl+C to stop it