Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:programmingblocks:loops [2018/06/07 13:01]
kniwwelino
en:programmingblocks:loops [2018/06/07 13:02] (current)
kniwwelino
Line 1: Line 1:
 +===== Loops =====
  
 +==== Repeat multiple times ====
 +{{:en:programmingblocks:loops_1.png|}}
 +
 +With this block you can repeat commands multiple times. Place the blocks to be repeated inside the loop. As soon as the program has accomplished the last block in the sequence, it will restart with the first block.
 +
 +Options:
 +  * The number of times the block or sequence of blocks should be repeated
 +
 +Example:
 +
 +{{:en:programmingblocks:loops_example.png|}}
 +
 +This example writes three times ''Hello!'' on the matrix.
 +
 +\\
 +==== Repeat while ====
 +{{:en:programmingblocks:loops_2.png|}}
 +
 +With this block, you can add a condition to a loop. As long (or until) as the condition is true, the blocks inside the loop will be repeated.
 +
 +Options:
 +  * ''while'': The loop will be repeated **as long as** the condition is true. As soon as it changes to false, the program goes to the first instruction after the loop.
 +  * ''until'': The loop will be repeated **until** the condition is true. This means that the blocks will be repeated as long as the condition is false. As soon as it changes to true, the program goes to the first instruction after the loop.
 +
 +\\
 +==== Count ====
 +{{:en:programmingblocks:loops_3.png|}}
 +
 +With this block you repeat a sequence of command blocks, and with each repetition, you change the value of a variable.
 +
 +Example:
 +
 +{{:en:programmingblocks:loops_example3.png|}}
 +
 +In the first loop, ''i'' is ''0'', then, after each loop it is increased by ''1'', until it reaches ''4''. In each loop, we use the value of ''i'' to switch on an LED in the matrix, then wait 0.5 seconds.
 +
 +\\
 +==== Break out of loop ====
 +{{:en:programmingblocks:loops_4.png|}}
 +
 +This block needs to be placed inside a loop. It can, for instance, be bound to another condition. As soon as the block is reached, the program jumps to the first instruction after the loop.
  • en/programmingblocks/loops.txt
  • Last modified: 2018/06/07 13:02
  • by kniwwelino