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:
- Navigate to the Application control view
- Observe that when the program starts, no sound is played
- Press the Canvas Toggle Button (Toggle widget output value now is true)
- Observe that after pressing the Canvas Toggle Button sound from the whistle library is played
- Press the Canvas Toggle Button (Toggle widget output value now is false)
- Observe no sound is played