RoboticsBeginnerPRJ-101

Light Follower Robot (LDR) Using Arduino

A robot that chases a torch beam using two light sensors.

Built and tested by Anju.A · Industrial Robotics Institute

Circuit diagram of the Light Follower Robot (LDR) using Arduino Uno
Circuit diagram · Arduino Uno
LevelBeginner
Build time1–2 hours
BoardArduino Uno
Parts9 components

What is the Light Follower Robot (LDR)?

An autonomous robot that moves towards light. Two LDR light-sensor modules sit at the front left and right; the Arduino compares them and turns towards the brighter side, so the robot follows a torch around the room.

How it works

  1. Two LDR modules at the front give a HIGH or LOW signal depending on how much light they see.
  2. Both see light: the robot drives forward.
  3. Only one side sees light: the robot turns towards that side.
  4. Neither sees light: it stops.

Parts list

ComponentQty
Arduino Uno1
LDR Sensor Modules2
L298N Motor Driver Module1
BO Gear Motors2
Robot Chassis1
Wheels and Caster Wheel1
18650 Lithium Batteries2
Battery Holder with Switch1
Jumper WiresAs needed

Software

  • Arduino IDE

Wiring and connections

FromConnect to
Left LDR VCC / GND5V / GND
Left LDR OUTPin 2
Right LDR VCC / GND5V / GND
Right LDR OUTPin 3
L298N IN1A0
L298N IN2A1
L298N IN3A2
L298N IN4A3
Battery +L298N 12V
Battery −L298N GND
Arduino GNDL298N GND

How to build the Light Follower Robot (LDR)

  1. Build the chassis with motors, wheels and caster.
  2. Mount the two LDR modules at the front, angled slightly left and right.
  3. Connect the left LDR to pin 2 and the right to pin 3.
  4. Connect L298N IN1–IN4 to A0–A3 and power it from the batteries.
  5. Upload the code.
  6. Adjust each module’s sensitivity screw in room light, then guide the robot with a torch.

Light Follower Robot (LDR) code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the Arduino Uno.

int leftSensor = 2;
int rightSensor = 3;

int LM1 = A0;
int LM2 = A1;
int RM1 = A2;
int RM2 = A3;

void forward()   { digitalWrite(LM1, HIGH); digitalWrite(LM2, LOW);  digitalWrite(RM1, HIGH); digitalWrite(RM2, LOW);  }
void left()      { digitalWrite(LM1, LOW);  digitalWrite(LM2, HIGH); digitalWrite(RM1, HIGH); digitalWrite(RM2, LOW);  }
void right()     { digitalWrite(LM1, HIGH); digitalWrite(LM2, LOW);  digitalWrite(RM1, LOW);  digitalWrite(RM2, HIGH); }
void stopRobot() { digitalWrite(LM1, LOW);  digitalWrite(LM2, LOW);  digitalWrite(RM1, LOW);  digitalWrite(RM2, LOW);  }

void setup()
{
  pinMode(leftSensor, INPUT);
  pinMode(rightSensor, INPUT);
  pinMode(LM1, OUTPUT);
  pinMode(LM2, OUTPUT);
  pinMode(RM1, OUTPUT);
  pinMode(RM2, OUTPUT);
}

void loop()
{
  int leftValue = digitalRead(leftSensor);
  int rightValue = digitalRead(rightSensor);

  if (leftValue == HIGH && rightValue == HIGH)      forward();
  else if (leftValue == LOW && rightValue == HIGH)  left();
  else if (leftValue == HIGH && rightValue == LOW)  right();
  else                                              stopRobot();
}

Real-world uses

  • Solar tracking systems
  • Automatic lighting
  • Light-seeking robot demos
  • Learning sensor-based steering

Frequently asked questions

What is a Light Follower Robot (LDR)?

An autonomous robot that moves towards light. Two LDR light-sensor modules sit at the front left and right; the Arduino compares them and turns towards the brighter side, so the robot follows a torch around the room.

What components are needed for the Light Follower Robot (LDR)?

You need: Arduino Uno (1), LDR Sensor Modules (2), L298N Motor Driver Module (1), BO Gear Motors (2), Robot Chassis (1), Wheels and Caster Wheel (1), 18650 Lithium Batteries (2), Battery Holder with Switch (1), Jumper Wires. Software: Arduino IDE.

Is the Light Follower Robot (LDR) project good for beginners?

Yes. It is rated beginner and takes about 1–2 hours to build, using the Arduino Uno. The guide on this page explains every connection and step.

Where can I get the code for the Light Follower Robot (LDR)?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Light Follower Robot (LDR)?

Yes. IRI sells a kit with the parts for this project (PRJ-101). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo