16.07.2015 Views

MicroBit-Quick-Start-Teacher-Guide

MicroBit-Quick-Start-Teacher-Guide

MicroBit-Quick-Start-Teacher-Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Quick</strong> <strong>Start</strong> <strong>Guide</strong> for <strong>Teacher</strong>sCreate a forever loop to update the display regularlyPREVIEWOur next section of code requires you to get the display to update regularly. We do this byusing a forever loop. This is to make sure that the program is always running. If we didn’tuse a forever loop, then we would have to write lots of lines of code to simulate our outcome.16Add a new line of code by pressing the + button.Select while. Running this program at this stagewould burn the battery. To fix this, add a pauseinstruction at the end of the loop. Click do nothingin the code, then on the code keyboard clickmicro:bit, more, then pause. Any pause durationwill work; in this case, we can even pick 0.Get the ‘egg’ to drop down the LED displayWe now want to get the egg to look like it is dropping down the display.17Before we can light up the LED beneath the firstLED, we need to unplot the original LED. Thiswill ensure a smooth change from one lit LED toanother, as if the egg is falling downwards. Selectmicro:bit from the keyboard and unplot. Unplotboth your basket position (x) and your egg position(obstacle x, obstacle y), as shown in the picture.18To get the egg to move down the display, weneed to change the vertical position of the egg(obstacle y). We can do this by adding 1 to thevalue of obstacle y, each second. Select obstacley. Select the assignment (:=) button, data andobstacle y + 1.19You now need to plot the new obstacle, using plotas previously. We will need to make sure that weslow down the board. Select micro:bit and pausefor 300 milliseconds. This will allow you to see thelights fall down the screen at a slower pace.Preview your program, you should notice the 'egg' fall down the board.24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!