#define in1 9 //PWM motors
#define in2 10 //PWM motors
#define he1 0 //Hall Effect 1
#define he2 1 //Hall Effect 2

int valorSensor1 = 0;
int valorSensor2 = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  digitalWrite(in2, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  valorSensor1 = analogRead(he1);

  while(valorSensor1 > 507){
    analogWrite(in1, 240);
    analogWrite(in2, 0);
    valorSensor1 = analogRead(he1);
    Serial.print("Sensor 1 = ");
    Serial.print(valorSensor1);
    Serial.print("   Sensor 2 = ");
    Serial.println(valorSensor2);
  }
  analogWrite(in1, 0);
  delay(2000);

  valorSensor2 = analogRead(he2);
  
  while(valorSensor2 > 498){
    analogWrite(in1, 0);
    analogWrite(in2, 130);
    valorSensor2 = analogRead(he2);
    Serial.print("Sensor 1 = ");
    Serial.print(valorSensor1);
    Serial.print("   Sensor 2 = ");
    Serial.println(valorSensor2);
  }
  analogWrite(in2, 0);
  delay(2000);
}
