Loading…
Loading…
Join 5,000+ parents and students receiving weekly STEM tips, competition updates, and exclusive workshop discounts.
Zero spam • Unsubscribe anytime • Proudly STEM-focused
A line follower robot is one of the most rewarding first projects in robotics education — and it teaches you more about sensors, motor control, and real-time decision making than almost any other beginner build. This guide will take you from zero to a working robot.
Components You Need Arduino UNO × 1, IR Sensor Module × 2, L298N Motor Driver Module × 1, DC Gear Motors × 2, Robot Chassis with wheels, 7.4V LiPo battery or 6×AA battery pack, jumper wires, and a black electrical tape track on white surface.
How It Works IR sensors emit infrared light and detect whether it reflects back. Black tape absorbs IR light (sensor reads HIGH), white surface reflects it (sensor reads LOW). The Arduino reads both sensors and steers the robot to stay on the line: if left sensor detects black, turn left; if right sensor detects black, turn right; if both see white, go straight.
Wiring the Circuit Connect the L298N ENA to Arduino pin 5 (PWM), IN1 to pin 6, IN2 to pin 7, ENB to pin 10 (PWM), IN3 to pin 8, IN4 to pin 9. Left IR sensor OUT to Arduino pin 2, Right IR sensor OUT to pin 3. Power the L298N from your battery; connect L298N 5V output to Arduino VIN.
The Code (simplified) Read both IR sensors each loop. If leftSensor is HIGH and rightSensor is LOW, turn left by reversing the right motor. If rightSensor is HIGH and leftSensor is LOW, turn right. If both are LOW (on white), go full speed ahead. If both are HIGH (junction or end), stop or slow down.
Troubleshooting Tips Robot oscillates wildly: your motors are too fast — reduce PWM speed from 255 to 150. Robot doesn't follow curves: increase sensor sensitivity using the blue potentiometer on the IR module. Robot overshoots turns: add a small delay (5–10ms) when turning.
FAQ
Q: What if I have 3 IR sensors? A: With 3 sensors, use the middle one as the baseline. If left sensor HIGH → turn left, right sensor HIGH → turn right, middle only → go straight. This gives smoother tracking.
Q: Can I use L293D instead of L298N? A: Yes. The L293D is smaller and fine for light robots, but can only supply 600mA per channel. For heavier robots, stick with L298N.
Q: How fast should the robot go? A: For beginners, set PWM to 120–150 (out of 255). This gives you time to debug. Speed up gradually once the logic works.
Q: What track width works best? A: Use 2cm wide black electrical tape with at least 5cm white border on each side. Curves should have a minimum radius of 15cm for a standard chassis.
Q: Does this work at night? A: IR sensors are not affected by darkness, but bright sunlight can interfere. Calibrate sensors indoors first.
Learn to build this exact robot in Week 1 of our Robotics Beginner Course at Mech-E-Tron — available in Chennai, Hyderabad and Tirupati. Our course covers line follower, obstacle avoidance robot, and 4 more builds in one month. Enrol at mechetron.com/courses/robotics-beginner-course.
Explore our hands-on courses and start your own innovation journey today.