I need to write a right turn code for a micromouse using sensors but I don't know where to start. Can you help me please? This is the algorithm we developed.
// Right turn while sensor 1 is OFF //
initialize RTcounter = 0;
if (sensor 6 == 0) {
RTcounter++;
if(sensor 6 == 1)
RTcounter++;
if(sensor 9 == 0)
RTcounter++;
if(RTcounter == 3)
right_turn();
reset RTcounter=0;
}
// Right turn while sensor 1 is ON //
if(sensor 1 == 1) {
straight();
initialize RTcounter = 0;
if (sensor 6 == 0)
RTcounter++;
if(sensor 6 == 1)
RTcounter++;
if(sensor 9 == 0)
RTcounter++;
if(RTcounter == 3)
right_turn();
reset RTcounter=0;
}
I know that I need to declare values for the revolutions. But how do I start to write the functions. Help me please. Thank you.