-> Control blocks are what tell your robot what to do and when to do it by using "Loops"
-> A loop is like a magic spell that says, "Do this action again and again until I say stop!"
If [something happens] Then [do something]
Notice that robot make 2 type of desicions.
If ["color sensor" reads green] Then [move FORWARD for 600 degrees at speed of 50%]
If ["color sensor" DON'T reads green] Then [move BACKWARD for 600 degrees at speed of 50%]
If [something happens]: robot detect something in its surrounding.
Then [do something]: the robot will decide what to do next.
Notice that robot make 4 type of desicions.
1- IF [no color] THEN [Not move (since there's no blocks outside the loop)]
2- IF[reads black] THEN[Move backward 500 degrees at the speed of 20].
3- IF[reads yellow] THEN[Make a pivot turn of 600 degrees at the speed of 20].
4- IF[reads white] THEN[Move forward 500 degrees at the speed of 20].
Notice that the order does not matter
'If-Else' gives your robot a choice. If [Option A happens], do option A. Else, if [Option A not happen], Option B happens.
'If something happens, do this. But if something else happens, do that instead!'
If [read green] then [move FORWARD 600 degrees at speed of 50%].
Else [if NO green] then [ove BACKWARD 600 degrees at speed of 50%].
STOP means telling your robot to take a break and EXIT means it's time for your robot to say goodbye to the program.
1- Robot [starts moving] backward at the speed of 50%.
2- It moves forever UNTIL the "color sensor" find red.
3- Robot stops moving.
4- Exit the program. The robot no longer listen to the code.
Notice that you don't have to press the "Stop" button on the screen. The robot turn off by itself.
Hint:
-> The speed of moving backward is 30%
Use: Ultrasonic Sensor (in the sensor).
-> Add a "Stop and Exit" block
Notice that you need to add a spin turn in between the loops
You can either use [Repeat Until] OR [Wait Until]
Don's worry, we will learn the SENSORS next!