ARDUINO CONTROLLED LINE FOLLOWER ROBOT CODE FILE




int right=9;
int left=10;
int LM1=2;
int LM2=3;
int RM1=4;
int RM2=5;
int r;
int l;

void setup(){
pinMode(right,INPUT);
pinMode(left,INPUT);
pinMode(LM1,OUTPUT);
pinMode(LM2,OUTPUT);
pinMode(RM1,OUTPUT);
pinMode(RM2,OUTPUT);
}

void loop(){
r=digitalRead(right);
l=digitalRead(left);

if(r==1 && l==1){
  digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
}

if(r==1 && l==0){
  digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
}

if(r==0 && l==1){
  digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
}

if(r==0 && l==0){
  digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
}


}