A compact, beginner-friendly line-following robot project maintained by the Cicuitology Club. This repository contains code, wiring guidance, and assembly notes for building a simple robot that follows a high-contrast path using infrared reflectance sensors and basic PID control.
- Simple, well-documented Arduino/C++ code for line following
- Sensor calibration and tuning guidance
- Wiring diagrams and recommended parts list
- Tips for improving reliability and speed
- Microcontroller: Arduino Uno / Nano or compatible
- Motors: 2 DC gear motors with motor driver (L298N, TB6612, or similar)
- Sensors: 3 or 5 IR reflectance sensors (e.g., QTR-1A / QTR-8A) or TCRT5000 modules
- Power: 6V–7.4V battery pack (NiMH or 2S LiPo with regulator)
- Chassis: small robot chassis with caster or ball wheel
- Misc: jumper wires, screws, breadboard or PCB mount, battery connector
- Connect left and right motors to the motor driver outputs.
- Connect motor driver inputs to two PWM-capable pins on the Arduino for speed control, plus two digital pins for direction if needed.
- Connect the IR sensors' VCC to 5V, GND to GND, and sensor outputs to Arduino analog/digital pins as used in the code.
- Power the motors from the battery via the motor driver VIN; keep Arduino powered via USB or a regulated 5V supply (do not power the Arduino 5V from an unregulated battery).
Refer to the Line_Following_Code folder for the exact pin mapping used in the example sketches.
The repository includes a Line_Following_Code directory containing Arduino sketches and helper libraries. The example sketch implements a basic line-following algorithm using sensor readings and a corrective steering term (P or simple PID).
- Open the Arduino IDE (version 1.8+ or Arduino CLI).
- Open the main sketch from
Line_Following_Code. - Select the correct board and serial port.
- Upload the sketch.
For Arduino CLI:
arduino-cli compile --fqbn arduino:avr:uno ./Line_Following_Code/YourSketch
arduino-cli upload -p COM3 --fqbn arduino:avr:uno ./Line_Following_Code/YourSketchReplace YourSketch with the sketch folder name and COM3 with your port.
- Place the robot over the line and run the calibration routine (if included) to read min/max sensor values.
- Use averaged readings and adjust thresholds used by the control algorithm.
- Tune the proportional (P) or PID gains incrementally: increase P until oscillation, then add small I/D terms if needed.
- Robot veers off: verify sensor voltages and wiring, check sensor height above surface (≈3–6 mm), and ensure good contrast between line and background.
- Motor jitter: add small delay or smoothing to PWM updates, check motor driver current limits, ensure solid power supply.
- Inconsistent readings: clean sensors, ensure stable lighting or use IR modules less sensitive to ambient light.
Line_Following_Code/— Arduino sketches and librariesLine Following Guide.pdf— design/assembly guide (if present in repo)
Contributions, improvements, and documentation fixes are welcome. Please open issues for bugs or feature requests and submit pull requests for code changes.
This project is open — please add a LICENSE file to specify the preferred license (MIT, Apache-2.0, etc.).
Maintained by the Cicuitology Club. For questions, open an issue or contact the repository administrators.