• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » Arduino Line Follower Robot Circuit

Arduino Line Follower Robot Circuit

Last updated on 12 November 2025 by Admin-Lavi Leave a Comment

This project is for Arduino Line Follower Robot Circuit.

Robot can follow black line on white floor.

It use Arduino, L298N motor driver and two IR sensors.

IR sensors see line and send signal to Arduino.

Arduino control motors and move robot on path.

Very simple and fun project.

Good for learning and school use.

Arduino Coding:

int leftIR = 2;
int rightIR = 3;
int in1 = 5;
int in2 = 6;
int in3 = 9;
int in4 = 10;

void setup() {
  pinMode(leftIR, INPUT);
  pinMode(rightIR, INPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop() {
  int leftVal = digitalRead(leftIR);
  int rightVal = digitalRead(rightIR);

  if (leftVal == 1 && rightVal == 1) {
    forward();
  } 
  else if (leftVal == 0 && rightVal == 1) {
    leftTurn();
  } 
  else if (leftVal == 1 && rightVal == 0) {
    rightTurn();
  } 
  else {
    stopMotor();
  }
}

void forward() {
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
}

void leftTurn() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
}

void rightTurn() {
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}

void stopMotor() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}

Code Explanation:

  • leftIR and rightIR are pins for IR sensor.
  • motorLeft and motorRight pins control L298N driver.
  • forward function make both motors go forward.
  • leftTurn and rightTurn spin motors opposite to turn robot.
  • IR sensor give 1 on white and 0 on black line.
  • Arduino read sensor and decide where to go.

Circuit Working:

Arduino Line Follower Robot Circuit Diagram

Parts List:

Part NameQuantity
Arduino UNO R31
L298N Motor Driver1
IR Sensor2
DC Motors with Wheels4
7V to 12V Battery1
SPST Toggle switch1
Robot Chassis1

IR sensors keeps watching the surface.

If both see white then robot goes straight.

If left sensor see black then robot turns left.

If right sensor see black then robot turns right.

If both see black then robot stops or wait.

Arduino read sensor signal.

Then send command to L298N driver.

Driver control motor speed and direction.

Robot follow black line on white floor by itself.

How to Build:

To build a Arduino Line Follower Robot Circuit follow the below steps:

  • Assemble all parts like in circuit diagram.
  • Left IR sensor output go to Arduino pin 2.
  • Right IR sensor output go to Arduino pin 3.
  • Both IR sensor VCC go to Arduino 5V.
  • Both sensor GND go to Arduino GND.
  • L298N IN1 go to Arduino pin 5.
  • L298N IN2 go to Arduino pin 6.
  • L298N IN3 go to Arduino pin 9.
  • L298N IN4 go to Arduino pin 10.
  • Motor A wires go to OUT1 and OUT2.
  • Motor B wires go to OUT3 and OUT4.
  • L298N 12V pin go to battery positive.
  • Battery negative go to GND.
  • Connect switch to the positive of battery.

Conclusion:

This is simple Arduino Line Follower Robot Circuit.

Good for learning Arduino basics.

IR sensors see the line.

Arduino read signals and run motors with L298N driver.

Robot move and follow path by itself.

Easy to make and is good for beginners and school project.

References:

How do I make a line follower robot with three IR sensor using Arduino Uno? 

Filed Under: Arduino Projects, Sensors and Detectors

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « Simple PIR Motion Detector Circuit

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar




Categories

  • Alarm Circuits (39)
  • Amplifier Circuits (67)
  • Arduino Projects (71)
  • Audio Circuits (101)
  • Automobile Circuits (19)
  • Battery Charger Circuits (54)
  • Free Energy (13)
  • Heater and Temperature Controllers (12)
  • High Voltage (1)
  • Indicator Circuits (44)
  • Inverter Circuits (16)
  • LDR Circuits (24)
  • LED and Lamps (134)
  • Meters and Testers (30)
  • Motor Controllers (19)
  • Oscillator Circuits (35)
  • Power Supply Circuits (94)
  • Remote Control Circuits (10)
  • Security and Protection (26)
  • Sensors and Detectors (107)
  • Solar Circuits (23)
  • Timer Circuits (33)
  • Transistor Circuits (68)
  • Transmitter Circuit (16)
  • Tutorials (8)
  • Water Level Controller (4)

Recent Posts

  • Arduino Line Follower Robot Circuit
  • Simple PIR Motion Detector Circuit
  • Simple Thermistor Based Fire Alarm Circuit
  • Fire Alarm Circuit using IC LM358
  • Smoke Detector Circuit using IC LM358

Recent Comments

  1. Henrik Arboe Jensen on Adjustable Voltage, Current Power Supply Circuit using Transistor 2N3055
  2. Admin-Lavi on FM Transmitter Circuit (100 meters range)
  3. DEVINDER SINGH on FM Transmitter Circuit (100 meters range)
  4. Admin-Lavi on Constant Voltage, Constant Current Battery Charger Circuit
  5. Bill on Constant Voltage, Constant Current Battery Charger Circuit

Copyright © 2025 | New Circuit Ideas