Line Follower

SRJT08203

Jyoti,a classmate of jugaadu,is preparing an automatic tray.the use of the tray is that it will automatically move on the the derired path.jyoti wants to use it in her family function such that it will reduce the number of waiters serving the food. She has asked jugaadu for help.Can you help jugaadu to make this tray?

  1. Motor Driver IC
  2. 2 IR sensors
  3. Bread board
  4. Arduino UNO UNO
  5. 12V Battery
  6. DIY Chassis Kit
  7. Jumper Cables
  8. Screw Driver
  9. Soldering Iron
  10. Glue gun
  11. Battery Connector
  12. USB Cable

    int mr1=7;
int mr2=6;
int ml1=8;
int ml2=9;
int l=10;
int r=11;
int irl=3;
int irr=4;

void setup() {
// put your setup code here, to run once:
pinMode(mr1,OUTPUT);
pinMode(mr2,OUTPUT);
pinMode(r,OUTPUT);
pinMode(ml1,OUTPUT);
pinMode(ml2,OUTPUT);
pinMode(l,OUTPUT);
pinMode(irr,INPUT);
pinMode(irl,INPUT);
Serial.begin(9600);
}

void loop() {
analogWrite(l,100);
analogWrite(r,60);
if(digitalRead(irr)==1 && digitalRead(irl)==1){
digitalWrite(mr1,1);
digitalWrite(mr2,0);
digitalWrite(ml1,1);
digitalWrite(ml2,0);
}else if(digitalRead(irr)==1 && digitalRead(irl)==0){
digitalWrite(mr1,0);
digitalWrite(mr2,1);
digitalWrite(ml1,1);
digitalWrite(ml2,0);
}else if(digitalRead(irr)==0 && digitalRead(irl)==1){
digitalWrite(mr1,1);
digitalWrite(mr2,0);
digitalWrite(ml1,0);
digitalWrite(ml2,1);
}else{
digitalWrite(mr1,0);
digitalWrite(mr2,0);
digitalWrite(ml1,0);
digitalWrite(ml2,0);
}
}