#define motor_1_speed   6   //pin, responsible for the speed of the first motor
#define motor_2_speed   5   //pin, which is responsible for the speed of the second motor
#define motor_1_dir     7   //pin, which is responsible for the direction of the first motor                //threshold 50. white - 20-30, black - 100-170
#define motor_2_dir     4   //pin, which is responsible for the direction of the second motor
#define sensor_1        A4  //pin to which the right sensor A0 is connected
#define sensor_2        A0  //pin, to which the left sensor A4 is connected

int v = 100;                //motor power
int p = 50;                 //limit value
                                 
void setup() {
  //setting ports 4-7 to output:
  for(int i = 4; i < 8; i++){
    pinMode(i, OUTPUT);          
  }
  //set the direction of movement of the robotic platform - forward:
  digitalWrite(motor_1_dir, 0);
  digitalWrite(motor_2_dir, 0);  
    
}

void loop() {
  //If both sensors "see" white, the robot moves forward:
  if (analogRead(sensor_1) < 50 && analogRead(sensor_2) < 50){
    analogWrite(motor_1_speed, v);
    analogWrite(motor_2_speed, v);
  }
  //if the right sensor "sees" black, the robot turns to the right:
  if (analogRead(sensor_1) > 50){
    analogWrite(motor_1_speed, 0);
    analogWrite(motor_2_speed, v);
  }
  //If the left sensor "sees" black, the robot turns to the left:
  if (analogRead(sensor_2) > 50){
    analogWrite(motor_1_speed, v);
    analogWrite(motor_2_speed, 0);
  }
}
