I have a mini-sumo robot but when it touches margins of the ring he turns around but he does not detect the oponent. Down I thought of a solution,I don't know HOW TO MEET TWO CONDITIONS IN THE SAME TIME WITHOUT EXCLUDING ONE OF THEM.
I want when (volt>50) go (200,200) not because go(50,-50) this move robot aside..I want to keep go(50,-50) when( linesensor_right < kWhiteThreshold ) but in the same time when (volt>50) then go(200,200)...all of this in the same condition..in the same if..or perhaps it's a ''while '' statemant but I don't know how..
I hope that you understand what I say
I'm a beginer.thanks guys !
-#
void SUMO()
{
digitalWrite(MOTOR1_PIN1, HIGH);
digitalWrite(MOTOR1_PIN2, HIGH);
digitalWrite(MOTOR2_PIN1, HIGH);
digitalWrite(MOTOR2_PIN2, HIGH);
linesensor_left = analogRead(A2);
linesensor_right = analogRead(A3);
Serial.println(linesensor_left);
Serial.println(linesensor_right);
float volts = analogRead(IRpin);
Serial.println(volts);
if ( linesensor_right < kWhiteThreshold ) put red condition HERE
{go(50,-50);
delay(1500);
Serial.println("RIGHT LINESENSOR TOUCHED");
}
else if ( linesensor_left < kWhiteThreshold )
{go(-50,50);
delay(1500);
Serial.println("LEFT LINESENSOR TOUCHED");
}
else if (volts > 150) {
go(255,255);
Serial.println("GO FORWARD");
}
else {
go(70,-70);
Serial.println("GO ASIDE");
}
}
-#