May 5, 2006

Some basics of the LOOP block

Using the pop-out menu (by selecting the orange icon, 4th down - FLOW), I select the LOOP block (2nd from left - others are WAIT, SWITCH, and STOP blocks).

When the LOOP block is first dropped, it is set for "Forever" - it will run until you manually end it. Using the drop-down menu, you can select sensors to determine if the loop breaks.

Now I've configured the LOOP for a count of 5. I've also dropped in a SOUND block - when the program runs, the configured sound or tone will play 5 times before the loop breaks.

I've added a STOP block just to be complete. The program will stop without it because it's set to loop 5 times. Just an old programming habit of actually STOPping the program.

For this image, I've just shown you how the LOOP block is set to be triggered by a SOUND sensor. You can set the limits (high or low) for triggering the break.


byronczimmer said...

Nice stuff!

I'm wondering if the WAIT block is strictly time based, or if you can wait for an event to occur (such as a sensor hitting a threshhold value or a variable reaching a certain count)? Heck, while we're at it, what are all those symbols on the left besides FLOW?

I'm also starting to wonder how robust (if at all) the support for subroutines is...

For example, it might be useful to create a 'sound off' subroutine which can either play a success (if 'true' is passed in) or a fail (if 'false' is passed in) tune that could then be reused as needed. "MyBlocks" was an attempt to do that under the RCX, but was limited to a single level, didn't permit recursion and otherwise was just really a space saving mechanism on the programming workbench.

I'm also starting to wonder if concurrent tasking is possible!

You're getting me really excited about this product... May and June are going to be long months!

Jim Kelly said...

1. Concurrent tasks are possible.

2. WAIT blocks can be matched to the sensors, brick buttons, and the timer.

3. MyBlocks do exist (and are very cool to work with) and can be reused (once they're in your library, they're in there until you delete them).

4. The symbols, from top (green circle) to bottom (4 red squares) are Common, Action, Sensor, Flow, Data and Advanced. Each of these have groupings of blocks that pop-out as sub-menus to select from. I'll try and document the sub-menus under each in a separate post very soon.


Brian Davis said...

On the subject of recursion, no, the MyBlocks can not "contain" themselves. But they can certainly be nested in other ways (i.e.- you can make a MyBlock that is composed of other MyBlocks, etc.)

Erin Howarth said...

My programs never seem to run properly when I use the stop block.

Related Posts Plugin for WordPress, Blogger...