Finding the Opponent
Use your sensors to turn your robot until the robot is facing the other robot, then charge!
if(sumo.IsLightOnFrontLeft() || sumo.IsLightOnFrontRight()) {
//this is our white line detection code
//notice this comes first!!
}else {
//always check in front first up
if(sumo.IsFrontLeft() && sumo.IsFrontRight()) //always check front sensors first
{
sumo.forward(80, 80);
}
else if(sumo.IsFrontFarLeft() && sumo.IsFrontLeft())
{
sumo.forward(8,10);
}
else if(sumo.IsFrontFarRight() && sumo.IsFrontRight())
{
sumo.forward(10,8);
}
else if(sumo.IsFrontFarLeft())
{
sumo.left(0, 9);
delay(20);
sumo.forward(10, 10);
}
else if(sumo.IsFrontFarRight())
{
sumo.right(9, 0);
delay(20);
sumo.forward(10, 10);
}
}
Last updated