Food Serving Tray Bot

TLMXB002

Shruti is Jugaadu’s classmates and she is preparing for an automatic tray. The use of the tray is to automatically move on the desired path. Shruti wants to use it in her family function such that it will reduce the number of waiters serving the food. She asked Jugaadu for help. Can you help Jugaadu in it?
Robotics and Digital kit
  1. Place two IR sensors downside of the bot and one IR in front of the bot.
  2. Connect IR modules with Arduino, switch, battery and servo motor using connecting wires on bread-board.
  3. Program the Arduino and upload the sketch Using A to B USB Cable.
  4. Test it by power it on.

    

int LS=8; // left sensor

int RS=7; // right sensor

int fr=6;

int LM1=2; // left motor

int LM2=3; // left motor

int RM1=4; // right motor

int RM2=5; // right motor

void setup()

{

pinMode(LS, INPUT);

pinMode(RS, INPUT);

pinMode(fr, INPUT);

pinMode(LM1, OUTPUT);

pinMode(LM2, OUTPUT);

pinMode(RM1, OUTPUT);

pinMode(RM2, OUTPUT);

Serial.begin(9600);

}

void loop()

{if(!(digitalRead(LS)) && !(digitalRead(RS)) &&(digitalRead(fr)==HIGH))

// Move Forward

{

digitalWrite(LM1, HIGH);

digitalWrite(LM2, LOW);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, LOW);

Serial.println(LS);

Serial.println(RS);

}

else if (!(digitalRead(LS)) && !(digitalRead(RS)) &&(digitalRead(fr)==LOW))//stop

{

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

Serial.println(LS);

Serial.println(RS);

}

if(!(digitalRead(LS)) && digitalRead(RS) &&(digitalRead(fr)==HIGH)) // Turn right

{

digitalWrite(LM1, HIGH);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

}

else if (!(digitalRead(LS)) && digitalRead(RS) &&(digitalRead(fr)==LOW))//stop

{

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

Serial.println(LS);

Serial.println(RS);

}

if(digitalRead(LS) && !(digitalRead(RS))&&(digitalRead(fr)==HIGH)) // turn left

{

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, LOW);

}

else if (digitalRead(LS) && !(digitalRead(RS)) &&(digitalRead(fr)==LOW))//stop

{

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

Serial.println(LS);

Serial.println(RS);

}

if(digitalRead(LS) && digitalRead(RS) && (digitalRead(fr)==LOW)) // stop

{

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

Serial.println(LS);

Serial.println(RS);

}

else if(digitalRead(LS) && digitalRead(RS) && (digitalRead(fr)==HIGH))//Stop

{

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);

digitalWrite(RM2, LOW);

Serial.println(LS);

Serial.println(RS);

}

}