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:
- Make sure that you have your KINI robot, and that it is connected to the internet.
- 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.
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 block
- 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).
- 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.
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!