Creating Loops in Blockly (Ages 9-13)

In this activity we are going to learn to use loop blocks, and you’ll get the chance to create your own loops in Blockly! In coding, a loop is a repeated set of instructions. We will be using loops to make KINI perform a set of actions multiple times.


Follow the steps below to create Blockly Loops in the KINI App:

  1. Make sure that you have your KINI robot, and that it is connected to the internet. KINI App Game Tab
  2. Open the app, and go to the Blockly tab by clicking the Blockly button in the bottom right corner. We will be using the two Repeat blocks to create our code.Kini App Blockly Tab
  3. To find all of the loop blocks, open the dark blue Loops tab on the left side.

    • There are three green loop blocks, but in this activity we will use the first blockKini App Blockly Tab
  4. Click the Repeat 10 times block and drag it into the Repeat Once block. The 10 times can be changed to whatever number you wish (this example uses 4 times).Repeat 10 times block is dragged into the Repeat Once block, and changed to repeat 4 times.
  5. Use the orange KINI tab to find action blocks to put in the Repeat 4 times block. These blocks make up a repeated sequence, also called a loop. KINI will perform these actions for the number of times that you select. 

Action blocks are retrieved from the orange Kini tab.

Action blocks are placed in the repeat 4 times block.

 

Congratulations! You just made your very first loop! 

 

The loop in the example above tells us that KINI will move backwards for 2 seconds, then stop, then rotate left for one second, then move forward for 20 centimeters, for 4 times in a row.


Great work everyone! You just learned how to use loop blocks to control your KINI! You can try out the code used in the example with your KINI, or try making your own! Good luck and have fun coding!