• 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 29 June 2026 by Admin-Lavi Leave a Comment

Arduino Line Follower Robot Circuit uses sensors and motors.

IR sensors look at floor all time and they find black line and white area, Arduino read these sensor signals and then it tell motor driver what to do.

Motor driver control wheels speed and direction and then robot follow black line by itself.

Arduino Code:

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 are for IR sensors.
  • MotorLeft and MotorRight pins control the L298N driver.
  • The forward function makes both motors move forward.
  • LeftTurn and RightTurn spin motors in opposite ways to turn the robot.
  • IR sensors give 1 on white and 0 on the black line.
  • Arduino reads the sensors and decides the direction.

Circuit Diagram:

Arduino Line Follower Robot Circuit Diagram

Parts List:

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

How to Build:

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

  • First, assemble all parts like in circuit diagram.
  • Next, left IR sensor output go to Arduino pin 2.
  • Then right IR sensor output go to Arduino pin 3.
  • Also, both IR sensor VCC go to Arduino 5V and both sensor GND go to Arduino GND.
  • Now L298N IN1 go to Arduino pin 5 and L298N IN2 go to Arduino pin 6.
  • Further, L298N IN3 go to Arduino pin 9 and L298N IN4 go to Arduino pin 10.
  • After that, motor A wires go to OUT1 and OUT2 and motor B wires go to OUT3 and OUT4.
  • Finally, L298N 12V pin go to battery positive, battery negative go to GND and then connect switch to the positive of battery.

Conclusion:

To conclude, this is simple Arduino Line Follower Robot Circuit which is good for learning Arduino basics.

Here, the IR sensors see the line and then Arduino read signals and run motors with L298N driver; then robot move and follow path by itself.

Also, this circuit is easy to make and is good for beginners and school project.

Filed Under: Arduino Projects, Automation Circuits, Hobby Circuits, 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
Next Post: Arduino Bluetooth Appliance Controller Circuit »

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar




Categories

  • 555 Timer Projects (132)
  • Alarm Circuits (80)
  • Amplifier Circuits (94)
  • Arduino Projects (103)
  • Audio Circuits (189)
  • Automation Circuits (150)
  • Automobile Circuits (40)
  • Battery Charger Circuits (86)
  • DIY Projects (413)
  • Free Energy (12)
  • Heater and Temperature Controllers (32)
  • High Voltage (24)
  • Hobby Circuits (229)
  • Indicator Circuits (63)
  • Inverter Circuits (17)
  • IoT projects (12)
  • LDR Circuits (47)
  • LED and Lamps (201)
  • Meters and Testers (44)
  • Mini Projects (372)
  • Motor Controllers (25)
  • Oscillator Circuits (70)
  • Power Supply Circuits (240)
  • Radio Frequency (8)
  • Remote Control Circuits (12)
  • Renewable energy (20)
  • Security and Protection (127)
  • Sensors and Detectors (234)
  • Solar Circuits (31)
  • Timer Circuits (62)
  • Transistor Circuits (178)
  • Transmitter Circuit (19)
  • Tutorials (31)
  • Voltage Regulator (43)
  • Water Level Controller (10)

Recent Posts

  • Low Current Controlled Battery Charger Circuit using LM723 IC
  • 741 Op-Amp Treble Booster Circuit
  • Simple Diode and Transistor Based Audio Limiter Circuit
  • Simple 500mW Speaker Driver Circuit
  • Easy DIY LM386 Audio Amplifier Circuit

Recent Comments

  1. Admin-Lavi on High Voltage Fence Charger Circuit
  2. egidio grzinic on High Voltage Fence Charger Circuit
  3. Logic OR Gate Circuit using Transistors - Circuit Ideas for You on Automatic Street Light Circuit using LDR
  4. Tony Gallegos on NTC Thermistor Based Temperature to Voltage Converter Circuit
  5. colin on Simple Single Transistor Audio Amplifier Circuit

Copyright © 2026 | New Circuit Ideas