Control (Part 2)

-> 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!"

"Wait" block

1-control-wait

"Wait Until" block

2-control-waitUntil

"Repeat" block

3-control-repeat

"Forever" block

4-control-forever

"Repeat Until" block

5-control-repeat-Until

"If-Then" block

6-control-if-Then

"If-Else" block

7-control-If-Else

"Stop and Exit program" block

8-control-exit

Build the entire robot by:

If you have not done so

IMG-2019 IMG-2018

"IF-THEN" block

6-control-if-Then

This robot it's a different robot: from Exploration way-2. So, don't worry if it's not the same.

If [something happens] Then [do something]

Any color (2)

This robot it's a different robot: from Exploration way-2. So, don't worry if it's not the same.

Notice that robot make 2 type of desicions.

Screenshot 2024 05 14 at 08.36.41

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-THEN x3" block

6-5-control-ifs

If [something happens]: robot detect something in its surrounding.

Then [do something]: the robot will decide what to do next.

CONTROL BABY ROBOT (1)

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].

6-6-control-ifs

Notice that the order does not matter

Observation for If-then


"If-Else" block

6-control-if-Then

'If-Else' gives your robot a choice. If [Option A happens], do option A. Else, if [Option A not happen], Option B happens.

Any color (1)

-> -> This robot it's a different robot: from Exploration way-2. So, don't worry if it's not the same.

'If something happens, do this. But if something else happens, do that instead!'

7-1-control-if-Else

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%].

-> -> This robot it's a different robot: from Exploration way-2. So, don't worry if it's not the same.


"Stop and Exit" block

8-control-exit

STOP means telling your robot to take a break and EXIT means it's time for your robot to say goodbye to the program.

a waitss BABY ROBOT (1)

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.

Screenshot-2024-05-14-at-07-07-34

Notice that you don't have to press the "Stop" button on the screen. The robot turn off by itself.

Key-Takeaways: why are loops important for programming?

Time for a quiz!

Question goes here

Challenge for you

A CHALLENGE YOU

Hint:

-> Pivot Turn (only one wheels moves). Remember that in pivot turn, the degrees is much more than the spin turn.

-> The speed of moving backward is 30%

Use: Ultrasonic Sensor (in the sensor).

untrasonic-hint

-> Add a "Stop and Exit" block

You-control

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!