KITT: a Line Following Robot
The purpose of this project is to develop an autonomous-line following vehicle for robotics/transport purposes. The vehicle may be used as a general robotics platform onto which other electronics may be added or explored.
KITT uses 5 IR sensors to detect the position of the line. It is driven using two geared DC motors, with a swiveling caster wheel in the front. The system is powered using 8 AA batteries.
This project was a joint effort with myself and Andrew Prata.
Supplies
The robot uses commonly available components online and in school maker spaces.
Chassis:
- 3mm MDF Board
- 18x M3 6mm Bolts
- 4x 30mm M3 Standoffs
- 5x 20mm M3 Standoffs
- 4x M3 Nuts
- Caster Wheel
Electronics:
- Arduino Nano
- H-Bridge
- 2x BO Motors w/ Wheels
- 5x TCRT5000 IR Sensors
- Breadboard
- 4x AA Batteries w/ Holder
- Jumper Wires
- 8" Neopixel Strip (Optional)
Tools:
- Hot Glue Gun
- Pliers
- Laser Cutter
- Soldering Iron (If electronics do not have headers preinstalled)
Software:
- Arduino IDE/PlatformIO
Chassis Design
We used a stacked approach was used that separated the components into different logical compartments. This allowed the vehicle to remain compact, and to use vertical space efficiently (and looks cooler).
For easy access to the electronics, we chose to attach the top plate using standoffs. These are 30 millimeters in length and allow for complete removal of the battery pack from the chassis for battery replacement.
The design files are attached below. All components were designed in Fusion 360.
Sensor Array Design
We chose to use TCRT5000 IR sensor to detect lines on the floor. The array setup consists of 5 IR sensors, linearly spaced by 19 millimeters. This layout gives a wide band of sensory input. As the sensors are placed in the front of the chassis, the vehicle can course-correct in advance.
The sensors are attached to the chassis using 20mm standoffs. This setup ensures the sensors are close to the ground and can pick up the line reliably.
Assembling the Chassis
The material used is a standard 3-millimeter MDF board and was cut using a laser cutter. We used hot glue to attach the side, bottom, and middle plates as shown. Four 30mm standoffs were used to connect the upper plate to the lower plate. We used four bolts and nuts to mount the caster wheel in place.
Electrical Schematic
The schematic is fairly simple, with an Arduino Nano MCU, an H-Bridge, 2 motors, and 5 IR sensors.
Mounting Electronics
We started by using hot glue to mount the motors to the chassis as shown. Using the 5 20mm standoffs and 10 6mm bolts, we mounted the sensors to their respective mounting points. We also added two Neopixel strips to the bottom of the vehicle. This was solely for looks (and to mimic the original KITT car from Knight Rider). Finally, we mounted the Arduino and H-bridge and connected all components using jumper wires.
Software
The robot uses a 32-state finite state machine to navigate various lines/intersections. Each sensor is treated as a digit in a binary number. When the sensor detects a line, it outputs a high signal (1). The program encodes the sensor inputs into a binary number, which is used to determine required motor control sequences. The software used is attached below.
Downloads
Testing
With the robot complete, we moved on to testing. We put together a test track with several twists, turns, and intersections. With trial and error, we refined our algorithm enough that it could pass 96% of our test cases. While the algorithm worked for us, different tracks and sensors may yield different results. Feel free to tweak our code to meet your needs!
Conclusion
And that concludes our project! While simple, this was a fun weekend activity and programming exercise. If you have any questions, don't hesitate to ask in the comments below.
If you enjoyed this project, please vote for it in the Microcontrollers Contest!