// Code used for the obstacle avoiding, line following robot.
int MotorControl[] = {4,5,6,7}; // Define the motor driver input controls
int LineSens    [] = {8,9,10 }; // Define Line sensor's L,C,R inputs 
int LineVal     [] = {0,0,0  };
char Direction;


void setup() {
  // put your setup code here, to run once:
pinMode(MotorControl, OUTPUT);
pinMode(LineSens    , INPUT );
Serial.begin(9600);
}

void Control(char x) {
  // Switch between the possible directions
  switch(x){
    case 'F':
      //set motor1 forward
    digitalWrite(MotorControl[0], 0 );
    digitalWrite(MotorControl[1], 1 );
      //set motor2 forward
    digitalWrite(MotorControl[2], 0 );
    digitalWrite(MotorControl[3], 1 );
    break;
    case 'B':
     //set motor1 backward
    digitalWrite(MotorControl[0], 1 );
    digitalWrite(MotorControl[1], 0 );
      //set motor2 backward
    digitalWrite(MotorControl[2], 1 );
    digitalWrite(MotorControl[3], 0 );
    break;
    case 'R':
      //set motor1 backward
    digitalWrite(MotorControl[0], 1 );
    digitalWrite(MotorControl[1], 0 );
      //set motor2 forward
    digitalWrite(MotorControl[2], 0 );
    digitalWrite(MotorControl[3], 1 );
    break;
    case 'L':
      //set motor1 forward
    digitalWrite(MotorControl[0], 0 );
    digitalWrite(MotorControl[1], 1 );
      //set motor2 backward
    digitalWrite(MotorControl[2], 1 );
    digitalWrite(MotorControl[3], 0 );
  }
  
  
}

void loop() {
LineVal[0] = digitalRead(LineSens[0]);
LineVal[1] = digitalRead(LineSens[1]);
LineVal[2] = digitalRead(LineSens[2]);
  // put your main code here, to run repeatedly:

if (LineVal[0] == 1){
  Serial.println("LEFT");
  Direction = 'L';
}else if (LineVal[1] == 1){
  Serial.println("CENTER");
  Direction = 'F';
}else if (LineVal[2] == 1){
  Serial.println("RIGHT");
  Direction = 'R';
};

Control(Direction);

delay(50);
}
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
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
btn3:1.l
btn3:2.l
btn3:1.r
btn3:2.r
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2