Repeat instructions on the condition

This block will run a coding strip continuously when it receives a positive input.

Repeat instructions on the condition can accept true or false input values.

LEGO® Powered UP App coding example: Use a switch to continiously run an instruction

Step 1: Add coding blocks

  • Flow block – Start
  • Flow block – Repeat instructions infinitely
  • Flow block – Repeat instructions on the condition
  • Widget block – Toggle widget
  • Sound and light block – Play from the laser sound library

Please note: without Repeat instructions infinitely block, the program will not pick up value changes caused by the Toggle Button press.

Step 2: Add Canvas Toggle Button with address 0

Step 3:

  1. Navigate to the Application control view
  2. Observe that when the program starts, no sound is played
  3. Press the Canvas Toggle Button (Toggle widget output value now is true)
  4. Observe that after pressing the Canvas Toggle Button sound from the whistle library is played
  5. Press the Canvas Toggle Button (Toggle widget output value now is false)
  6. Observe no sound is played

Back to Flow blocks page