Harsh Dethe
Published © CC BY-NC-SA

Simple Line Follower Robot

Simple line following robot using IR proximity sensors, Arduino UNO and motorsheild.

IntermediateFull instructions provided1 hour12,356
Simple Line Follower Robot

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Motor Shield
×1
Geared DC Motor
×2
Wheels
×2
Caster wheel
×1
IR Proximity sensor
×2
Battery
×1
Toggle Switch
×1
Female-Female jumper wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

LineFollowing Robot

Arduino
Check Serial monitor for debugging.
#include<AFMotor.h>

AF_DCMotor motor1(2,MOTOR12_1KHZ); //Motors
AF_DCMotor motor2(3, MOTOR12_1KHZ);

int sensorPin1 = A4; //LDR 
int sensorPin2 = A5;



void setup() 

 {
  
  Serial.begin(9600);   // Start Serial & set pin to output  
  Serial.println("Motor test!");
  motor1.setSpeed(250); 
  motor2.setSpeed (250);
  
  }

void loop() 

{
  int sensorValue1 = analogRead(sensorPin1);// Read the sensor pin
  int sensorValue2 = analogRead(sensorPin2);
 
  
  //if light intensity it High 
  if (sensorValue1 > 50)
  {
  Serial.println("Turn Right");
  motor1.run(FORWARD);
  }
  else
  {
    motor1.run(RELEASE);
  }
   
  if (sensorValue2 > 50)
  {
  Serial.println("Turn Left");
  motor2.run(FORWARD);
  }
  else
  {
    motor2.run(RELEASE);
  }
}

Credits

Harsh Dethe

Harsh Dethe

30 projects • 70 followers
Electronics hobbyist, AI Enthusiast. I like to play with technology.

Comments