A line follower robot is one of the most rewarding beginner builds in robotics. It moves on its own, reacts to its environment, and demonstrates a real feedback loop in physical form. Most tutorials assume you will write Arduino code. Still, the line follower robot circuit can be built and made fully functional using only hardware logic, with no microcontroller and no programming required. All decision-making occurs within a comparator IC that reads the IR sensors and drives the motor driver directly.
This guide walks through the complete no-code approach, from how the circuit works to a full parts list, wiring diagram, and calibration steps.
How a No-Code Line Follower Works
Before picking up a soldering iron, understanding the signal flow makes the build straightforward.
In a no-code build, the comparator inside each TCRT5000-based sensor module replaces the microcontroller entirely. Each module includes an onboard LM393 comparator. When the sensor is over a white surface, reflected IR is high, and the comparator outputs a digital HIGH. When it is over a black line, reflected IR drops, and the output goes LOW. These HIGH and LOW outputs connect directly to the L298N motor driver input pins, creating forward, left-turn, and right-turn behaviour without any code involved.
The core insight: Two IR sensors and one L298N motor driver are all the logic components needed. The LM393 comparator built into each sensor module handles all decision-making that a microcontroller would otherwise perform.
Components Required
Full Parts ListHow the IR Sensor Logic Drives the Motors
The L298N has four direction control pins: IN1 and IN2 for Motor A (left wheel), IN3 and IN4 for Motor B (right wheel). To make the motor spin forward, IN1 goes HIGH and IN2 goes LOW. To stop it, both go LOW.
In the no-code circuit, the digital output of the left IR sensor connects to IN1, and the digital output of the right IR sensor connects to IN3. IN2 and IN4 are held permanently LOW by connecting them to GND. ENA and ENB jumpers stay in place for full speed.
| Left Sensor | Right Sensor | Left Motor | Right Motor | Robot Behaviour |
|---|---|---|---|---|
| HIGH (white) | HIGH (white) | Forward | Forward | Drive straight |
| LOW (black) | HIGH (white) | Stop | Forward | Turn left toward the line |
| HIGH (white) | LOW (black) | Forward | Stop | Turn right toward the line |
| LOW (black) | LOW (black) | Stop | Stop | Robot halts (line lost) |
When both sensors see white, both motors run, and the robot goes straight. When the left sensor crosses the black line, IN1 goes LOW, stopping the left motor while the right motor continues, turning the robot back to the left until the left sensor returns to white. The robot self-corrects continuously, following the line without a single line of code.
Wiring the Circuit
Important: All grounds must share a common GND reference among the IR sensors, the L298N, and the battery pack. Floating grounds are the most common cause of erratic behaviour in this build.
IR Sensors → L298N
| IR Sensor Pin | L298N Pin |
|---|---|
| Left sensor D0 (digital out) | IN1 |
| Right sensor D0 (digital out) | IN3 |
| Both sensor VCC | 5V output from L298N |
| Both sensor GND | GND |
L298N → Motors and Power
| L298N Pin | Connection |
|---|---|
| OUT1, OUT2 | Left DC motor terminals |
| OUT3, OUT4 | Right DC motor terminals |
| 12V input | Battery positive |
| GND | Battery negative |
| IN2 | GND (permanent LOW) |
| IN4 | GND (permanent LOW) |
| ENA jumper | Keep in place (full speed) |
| ENB jumper | Keep in place (full speed) |
Power note: The L298N's onboard 5V regulator supplies power to both IR sensor modules when the battery voltage is between 7V and 12V — removing the need for a separate 5V regulator in the build. This is why a 2S 18650 pack (7.4V) is recommended over 4×AA (6V).
Physical Sensor Placement
Sensor placement has a greater effect on line-following performance than any other mechanical factor.
Mount the two IR sensor modules at the front of the chassis, facing downward, approximately 5 to 10 mm above the track surface. Space them roughly 20 to 30 mm apart, with the gap between them positioned directly over where the centre of the line would be during straight travel.
- Mount height: 5 mm above track surface — enough margin for uneven floors, close enough for strong contrast
- Sensor spacing: 20–25 mm apart for standard 18 mm wide black tape lines
- Sensors face downward toward the track, not at an angle
- Gap between sensors centred over the expected line path
- Keep ambient light sources away from sensors during initial testing
⚠ Height limits: Lower than 3 mm risks sensors touching an uneven surface and false readings. Higher than 10 mm reduces reflectance contrast between black and white, making the LM393 comparator less decisive in its output switching.
For a standard 18 mm wide black tape line on white paper, a sensor spacing of 25 mm works well. The line sits entirely under one sensor at a time when the robot drifts off centre, giving the circuit a clear correction signal. If the sensors are too far apart, the robot may miss narrow curves because both sensors can be simultaneously on white even when the robot is off track.
Calibrating the Sensitivity Potentiometer
Each TCRT5000 module has a small blue potentiometer that adjusts the LM393 comparator threshold. This calibration step is essential and takes less than two minutes per sensor.
Power the robot while it is stationary on the track. Observe the indicator LED on each sensor module.
Place the left sensor directly over the white background. The LED should be ON.
Slide the robot so the left sensor is directly over the black line. The LED should turn OFF.
If it does not change state, turn the potentiometer clockwise in small increments using a small flathead screwdriver and test again.
Repeat steps 2–4 for the right sensor.
Final check: place both sensors on white — both LEDs ON. Move both over black — both LEDs OFF.
Ambient light fix: If the robot has difficulty distinguishing surfaces under bright ambient light, shield the sensors with a small piece of black foam or cardboard to reduce ambient IR interference. This is especially helpful under direct sunlight or fluorescent ceiling lights.
Setting Up the Track
A clean, high-contrast track is as important as the circuit itself. Use 18 to 25 mm wide black electrical tape or black insulating tape on a white A3 sheet of paper or white floor tile. Avoid glossy surfaces that reflect IR strongly at certain angles.
| Track Type | Result | Recommendation |
|---|---|---|
| Black tape on white A3 paper | Excellent contrast | ✅ Best for beginners |
| Black tape on white floor tile | Very good contrast | ✅ Durable option |
| Black tape on glossy surface | IR reflections cause false reads | ⚠ Avoid |
| Dark colour on dark background | Insufficient IR contrast | ✗ Will not work |
| White on black (inverted) | Works with reversed calibration | ⚠ Recalibrate pot |
The line should have gentle curves for a first test. Tight turns with a radius under 100 mm may challenge a simple two-sensor no-code robot, since both sensors can simultaneously be on white during a sharp turn, triggering a stop condition.
For testing, a large oval loop on an A2 sheet of white paper is the most forgiving first track. Once the robot reliably follows the oval, introduce a figure-eight track to test left and right turns in sequence.
Common Issues and Fixes
For a deeper understanding of how IR sensor feedback drives robot behaviour, the ThinkRobotics sensor guide and the motor drivers collection carry all components needed to extend this build.
Upgrading to a Coded Version Later
The no-code circuit is a complete, working robot. It is also a foundation that transfers directly to an Arduino-based build if you want to add features later. The same TCRT5000 sensors connect to two digital input pins on an Arduino Uno. The same L298N wires to four digital output pins. Once the hardware is in place, you can add:
- Speed control via PWM for smoother movements and better curve handling
- A third centre sensor for improved tracking accuracy
- An HC-SR04 ultrasonic sensor for obstacle avoidance without starting from scratch
- PID control for competitive-level line following on narrow or curved tracks
For the full Arduino-coded version of this build, including a wiring diagram, sample firmware, and PID tuning guidance, the ThinkRobotics line follower robot guide covers the transition from hardware logic to software-controlled motion in detail.
Technical reference: For a comprehensive reference on IR sensor operating principles and comparator circuit design, the TCRT5000 datasheet from Vishay provides full optical and electrical specifications, including response curves and threshold-voltage behaviour.
Conclusion
A line follower robot circuit built entirely from hardware logic is one of the cleanest introductions to autonomous robots available. Two IR sensor modules, one L298N motor driver, a two-wheel chassis, and a battery pack are all that is needed: no code, no programmer, no IDE. The LM393 comparator inside each sensor module handles all the decision logic. Get the sensor height right, calibrate the potentiometers, and the robot will follow a line reliably from the first power-on. When you are ready to add intelligence through code, every component in this build carries forward unchanged.
Frequently Asked Questions
Two sensors are the minimum for a functional no-code build. A left sensor and a right sensor provide enough information for straight travel, left correction, and right correction. Adding a third centre sensor requires a comparator IC such as the LM393 in a separate circuit for a no-code implementation, which adds complexity without significant benefit at the beginner level. Two TCRT5000 modules are sufficient for this build.
The TCRT5000 responds to IR reflectance contrast, not visible colour. Black on white gives the strongest contrast. Dark colours on light backgrounds generally work. White on black also works, but requires recalibrating the potentiometer in the opposite direction. Coloured lines on white backgrounds may not provide enough IR contrast for reliable detection — always test before committing to a track design.
No. With two sensors and pure hardware logic, the robot cannot distinguish a T-junction from a straight section because both sensors see black simultaneously at an intersection, triggering a stop. Handling intersections requires additional sensors and decision logic, which means moving to an Arduino-based coded approach.
A 2S 18650 Li-ion pack at 7.4V or a 6×AA pack at 9V both work well. The L298N's onboard regulator accepts either voltage and provides a stable 5V to the sensor modules. Avoid 4×AA at 6V — the L298N regulator requires at least 7V input to output a stable 5V to the sensors.
If the robot stops on curves rather than correcting, both sensors are simultaneously reading the black line, which causes both motors to stop. This happens when sensors are spaced too far apart relative to the line width. Reduce sensor spacing to 20 to 25 mm and ensure the line is wide enough (at least 18 mm) that only one sensor crosses it at a time during a curve.
Ready to Build Your Line Follower?
TCRT5000 sensors, L298N driver, 2WD chassis, and all the parts you need — shipped fast across India.