Changing Outcomes in Blockly - Part Two (Ages 9-13)

Hello everyone! Welcome back to part two of the Changing Outcomes in Blockly activity. By the end of the activity, you’ll be able to change the outcome of a code by adding and modifying blocks!


Before we begin:

  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. Understand the basics of Blockly - if you don’t, go to the “Introduction to Blockly” activity before this one.
  4. This is the second part of the Changing Outcomes in Blockly activity, so make sure to finish the first part before this one. 

We’re going to talk about how changing a single block impacts the final outcome: 

  1. To start, we’ll choose an initial outcome, and then write the code to make that outcome happen. For this example, let's say that we want the outcome to be that KINI will be forwards and to the right of where it started. 
  2. To get this result, we’ll make KINI move forwards for 20cm, turn right, then move forwards for 1 second.A blockly code is shown that makes Kini first move forwards for 20cm, then rotate right for one second, and finally move forwards for 1 second.
  3. As you can see by this drawing of KINI’s movements, the outcome that we wanted happened. KINI moved forwards and to the right.A drawing is shown that depicts Kini's movements; first Kini moves forwards for 20cm, then rotates right for one second, and finally moves forwards for 1 second. Kini's final position is forwards and to the right of where it started.
  4. What if we want to change this code so that KINI moves forwards and to the left. To change the outcome of this code, we can break it up into smaller pieces:

    • The first piece of the code is “Move Forwards for 20cm”
      • If we want KINI to move forwards and to the left, does this have to change? No!
    • The second piece of the code is “Rotate Right for 1 Second”
      • If we want KINI to move forwards and to the left, does this have to change? Yes!
      • If you look at the drawing, this block is the action that makes KINI go right, which we don’t want.
      • What can we do to change the outcome? We can use the Rotate Left block to make KINI go to the left instead of the right.The change in the Blockly code is shown that makes Kini first move forwards for 20cm, then rotate left for one second, and finally move forwards for 1 second.
    • The last piece of the code is “Move Forwards for 1 Second”
      • If we want KINI to move forwards and to the left, does this have to change? No!

All we did to change the code was change the Turn Right block to a Turn Left block. This may seem like a small change, but it changed the outcome of our code completely. If you make a new drawing of this code, you’ll see that KINI moves forward and to the left, just like we wanted. You can see that every detail in coding matters, because changing  a single block impacts the entire code!A drawing of Kini's movement after the change is shown. Kini now moves forwards for 20cm, then rotates left for one second, and finally moves forwards for 1 second. Kini's final position is changed to be forwards and to the right of where it started.


Now that you’ve learnt about outcomes, each time you code KINI, try to first think of the outcome, then use blocks to make that outcome happen. Good luck, and have fun coding!