Rotate 180° with help of the line follower sensor


#1

Hello,

I have a black line with a mBot in the middle of it. What I want to do is to rotate the mBot for 180 degrees, so it would face the other half of the line. My idea is to use line follower in a loop to make the robot rotate until it founds the black line. However, I’m not sure how to do it because the mBot is on the black line at the beginning so the loop will finish immediately.

Could anyone help me?

TIA. Regards.


#2

turn left
wait .5 sec
if line follow > 0
then turn left

the first turn left with the 0.5 sec wait gets you off the black line
you then continue the turn until you are back on the line