Before we begin:
- 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.
- Understand the basics of Blockly - if you don’t, make sure to visit the “Introduction to Blockly” activity before this one.
What is a condition?
- A condition is something that must happen for something else to happen
- In real life, you could say “One condition for you to do your homework is a quiet area”
- In this example, before you can do your homework, you must have a quiet area, which is the condition
- Conditions can be used to control KINI in Blockly
- KINI will only do a certain action if the condition happens
How to use conditions in Blockly:
- To find blocks that we use to make conditions, go to the light blue Logic tab on the left side of the screen.
- For this example, we will use the “If/Do/Else” block. Click it for it to appear beside the two repeat blocks.
Drag the “If/Do/Else” block and snap it into place in the Repeat Forever block.
- The Repeat Forever block is used for conditions, because we don’t just want to see if the condition happened one time, but always
The condition goes into the "If" part of the block
- To find condition blocks, go to the green Sensors tab. This example uses the distance sensor.
The action that happens if the condition is true goes into the “Do” part of the block
- To find action blocks, go to the orange KINI tab. This example uses a rotate left block
The action that happens if the condition is false goes into the “Else” part of the block
- To find action blocks, go to the orange KINI tab. This example uses a move forward block
Congratulations everyone! You just learnt what a condition is, and how to use conditions in Blockly. You can try out this same code, and even try adding your own conditions to make it better!
Now that you’ve learnt about conditions, each time you code KINI try using conditions to solve problems. Good luck, and have fun coding with conditions!