constantly loops when the B button is pressed. That way we have the benefits of both the event block and the
loop
block without needing complicated programming.
If Condition Statements
We'll use
if/else
statements once again to check the sensor readings and move the micro:bot:
Case 1
:
If both are reading the same,
move forward
.
Case 2
:
If the left sensor sees a dark black line but the other does not,
move forward and a little to the left
toward the dark black line closer to the left side of the micro:bot.
Case 3
:
If the right sensor sees a dark black line but the other does not,
move forward and a little to the
right
toward the dark black line closer to the right side of the micro:bot. There are slight differences in
the motors and wheels so we tweak the left motor strength a bit so that the micro:bot actually turns
toward the right (
50 + 5
).