Lesson on Loop Block
A set of instructions to do over and over and over until
something else happens. It may be that touch sensor
is pressed or the sound sensor detects a noise or the time reaches
infinity.
When dropping a block inside a LOOP block, continue to
hold down the mouse button and move the new block
inside the Loop block until the loop block explains.
A Simple MOVE Block inside a Loop Block

The Control Section of the Loop Block

The Control Section of the Loop Block configured for Time

Loop Block set to forever

A Loop Block configured to break using a touch sensor

Nested Loop
This means a loop inside a loop. When the program runs,
any blocks inside the outer loop block will run. First, the inner loop will run three times
(executing MOVE and SOUND blocks inside it) and then break. Then the Light sensor will send
a True/False Logic response to the outer loop block's data plug. If the Light sensor does not
detect a light level greater than 90, the outer Loop block will not break and will run whatever
is inside it again.

There is a data wire connecting the Light sensor to the outer loop block. In the control section of the outer loop block, the Logic option is selected and wait until it receives a True response from the Light sensor block.
If the Light sensor block does not detect a light level greater than 90, the Yes/No data plug sends a False signal to the outer loop block causing the outer loop block to loop again.
0 comments:
Post a Comment