Back to: Robotics & Artificial Intelligence (Class IX)
An Edge Avoider Robot is a self-operating robot that moves safely on a surface while avoiding edges. It prevents itself from falling off a table or stairs by detecting edges using two IR sensors.
How It Works
- The robot moves forward when both IR sensors detect a surface.
- If one sensor detects an edge, the robot stops and turns to stay on the surface.
- If both sensors detect edges, the robot moves backward and turns to avoid falling.
Components Required
- Arduino Uno – The brain of the robot
- Two IR Sensors – Detect edges
- L298N Motor Driver – Controls motors
- Two DC Motors – Provide movement
- Power Source – 9V battery or Li-ion battery pack
- Chassis – Robot body
- Jumper Wires – For connections
Connections

Programming
int LS=7;
int RS=8;
int LM1=9; // left motor
int LM2=10; // left motor
int RM1=11; // left motor
int RM2=12; // left motor
void setup()
{
Serial.begin(9600);
pinMode(LS, INPUT);
pinMode(RS, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
}
void loop()
{
Serial.println(digitalRead(LS));
Serial.println(digitalRead(RS));
if((digitalRead(LS)==0) && (digitalRead(RS)==0)) //s
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
if((digitalRead(LS)==0) && (digitalRead(RS)==1)) //r
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, HIGH);
}
if((digitalRead(LS)==1) && (digitalRead(RS)==0)) //l
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if((digitalRead(LS)==1) && (digitalRead(RS)==1)) //f
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
}
Working Mechanism
🔹 Both sensors detect surface → Move forward
🔹 Left sensor detects edge → Turn right
🔹 Right sensor detects edge → Turn left
🔹 Both sensors detect edges → Move backward and turn
Applications of Edge Avoider Robot
✅ Prevents Falling from Heights – Useful for table-top robots
✅ Industrial Automation – Used in automated warehouses
✅ Smart Cleaning Robots – Like robotic vacuum cleaners
✅ Autonomous Navigation – Helps in intelligent movement