const int DIR = 12;
const int STEP = 13;
const int REV = 200;
const int DER = 2;
const int STIP = 3;
const int RIR = 4;
const int LIR = 5;
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(STEP, OUTPUT);
pinMode(DIR, OUTPUT);
pinMode(STIP, OUTPUT);
pinMode(DER, OUTPUT);
pinMode(RIR, INPUT);
pinMode(LIR, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
Serial.println("Area Scanning");

if((digitalRead(RIR) == 1)&&(digitalRead(LIR) == 1)){foward();}
if((digitalRead(RIR) == 0)&&(digitalRead(LIR) == 1)){turnRight();}
if((digitalRead(RIR) == 1)&&(digitalRead(LIR) == 0)){turnLeft();}
if((digitalRead(RIR) == 0)&&(digitalRead(LIR) == 0)){Stop();}
}
void foward() {
int W = digitalRead(RIR);
int Y = digitalRead(LIR);

digitalWrite(DIR, HIGH);
digitalWrite(DER, HIGH);
for(int x = 0;x<REV;x++){
digitalWrite(STEP, HIGH);
digitalWrite(STIP, HIGH);
delayMicroseconds(200000);
digitalWrite(STEP, LOW);
digitalWrite(STIP, LOW);
delayMicroseconds(200000);
}
Serial.print("Right ir sensor value : ");
Serial.println(W);
Serial.print("Left ir sensor value : ");
Serial.println(Y);

Serial.println("Vehicle intiated to go forward");
}
void turnRight() {
int W = digitalRead(RIR);
int Y = digitalRead(LIR);

digitalWrite(DIR, HIGH);
digitalWrite(DER, LOW);
for(int x = 0;x<REV;x++){
digitalWrite(STEP, HIGH);
digitalWrite(STIP, HIGH);
delayMicroseconds(2000);
digitalWrite(STEP, LOW);
digitalWrite(STIP, LOW);
delayMicroseconds(2000);
}
delay(5000);
Serial.print("Right ir sensor value : ");
Serial.println(W);
Serial.print("Left ir sensor value : ");
Serial.println(Y);

Serial.println("Vehicle initiated to turn right");
}
void turnLeft() {
int W = digitalRead(RIR);
int Y = digitalRead(LIR);

digitalWrite(DIR, LOW);
digitalWrite(DER, HIGH);
for(int x = 0;x<REV;x++){
digitalWrite(STEP, HIGH);
digitalWrite(STIP, HIGH);
delayMicroseconds(2000);
digitalWrite(STEP, LOW);
digitalWrite(STIP, LOW);
delayMicroseconds(2000);
}
delay(5000);
Serial.print("Right ir sensor value : ");
Serial.println(W);
Serial.print("Left ir sensor value : ");
Serial.println(Y);

Serial.println("Vehicle initiated to turn left");
}
void Stop() {
int W = digitalRead(RIR);
int Y = digitalRead(LIR);

digitalWrite(DIR, LOW);
digitalWrite(DER, LOW);
for(int x = 0;x<REV;x++){
digitalWrite(STEP, LOW);
digitalWrite(STIP, LOW);
delayMicroseconds(2000);
digitalWrite(STEP, LOW);
digitalWrite(STIP, LOW);
delayMicroseconds(2000);
}
Serial.print("Right ir sensor value : ");
Serial.println(W);
Serial.print("Left ir sensor value : ");
Serial.println(Y);

Serial.println("Vehicle intiated to go backward");
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
stepper1:A-
stepper1:A+
stepper1:B+
stepper1:B-
A4988
drv1:ENABLE
drv1:MS1
drv1:MS2
drv1:MS3
drv1:RESET
drv1:SLEEP
drv1:STEP
drv1:DIR
drv1:GND.1
drv1:VDD
drv1:1B
drv1:1A
drv1:2A
drv1:2B
drv1:GND.2
drv1:VMOT
A4988
drv2:ENABLE
drv2:MS1
drv2:MS2
drv2:MS3
drv2:RESET
drv2:SLEEP
drv2:STEP
drv2:DIR
drv2:GND.1
drv2:VDD
drv2:1B
drv2:1A
drv2:2A
drv2:2B
drv2:GND.2
drv2:VMOT
stepper2:A-
stepper2:A+
stepper2:B+
stepper2:B-
ir1:GND
ir1:VCC
ir1:DAT
ir2:GND
ir2:VCC
ir2:DAT