Skip to content

Build a program containing a loop

What you will learn

  • The loop flow functionality
  • Use the Do While control block in your program
  • Connect input and outputs

In the following example we are creating a program which runs a loop that executes the "wait" command five times and then stops. This tutorial uses a Do While function block connected with a condition value in order to explain the basic concepts of linking and program flow. Alternatively, you may also achieve the same functionality using the For Loop. But for learning purposes, this tutorial shows how to manually simulate a For Loop. For Loop usage is described here.

Video Tutorial

Step-by-step Guide

  1. Create a new program.

  2. Add a Loop Do While from Control Structures library to the builder canvas.

  3. Add a Compare Integer from Basic Function Blocks library inside the Loop.

  4. Add a Wait from Basic Function Blocks library inside the Loop and after the counter.

  5. Select Set Parameter on the Wait function block and set waiting time to 0.5 seconds.

  6. Select Set Parameter on the Compare Integer function block as shown in the picture.

    Set parameter of the loop

  7. Link operand 1 to the output of the loop cycle counter by pressing the link-button link button and selecting the cycle count output of the Do While loop.

    Set the loop condition

    Select the counter as a reference

    Save the loop

  8. Assign the other operand to 5 (this is the maximum number of runs).

  9. Assign to the Condition operator a '<' sign.

  10. Save & Run the program

After the desired number of iterations in the loop, the 'Loop Demo' program should stop because the condition is resolved to false and therefore the cycle finishes.