About this project

 

In this simple introductory project, you can teach your pupils how to create flashing images using the BBC micro:bit's LED grid. This is a quick and accessible way to introduce new users to the basics of Microsoft Block Editor and how online code can be applied to external devices.

 

What you'll need

 

1 x BBC micro:bit

1 x Micro USB

1 x Computer or tablet

2 x AAA Batteries & Battery Holder (optional)

 

Getting started

 

To get started with the BBC micro:bit, visit the official website and sign in using your unique facilitator code. This should have been provided when you first received your BBC micro:bit order. Please email BBCmicrobit@bbc.co.uk if you have not received one.

 

After entering your facilitator code, you will be prompted to authenticate your account by entering your username and password from an existing account - such as Facebook, Office 365 or Microsoft. Read and agree to the terms and conditions to complete the sign-in process.

 

Signing in allows you to save and retrieve projects, publish coding scripts to the BBC micro:bit website, set up restricted access groups for your students and share scripts with other users. You can create code on the BBC micro:bit website without signing in, but you won't be able to save your projects and return to them.

 

Project walk through

 

  • Go to the BBC micro:bit website and click 'create code'.

 

  • Under 'Microsoft Block Editor', click 'New project' to open the block editor tool.

 

  • Along the left-hand side of the screen you should see a drop-down menu with titles such as 'basic' 'input', 'loops' etc. Clicking on any of these titles reveals a number of tiles representing different coding commands.

 

  • To get started, click 'basic' and find the tile entitled 'show leds'. Click on this tile and drag it into the main space at the centre of the screen.

 

  • You can select which of the individual LED displays will be illuminated on the BBC micro:bit's array by checking the boxes within this tile. To create a heart shape, check the boxes indicated in the image below:

BBC micro:bit

  • To see a preview of how this will look on your BBC micro:bit, click 'run'.

 

  • Now we want to tell the heart to flash on and off. To do this, click 'basic' under the command menu and this time select the 'pause (ms)' tile. This will command the code to freeze an action for the selected amount of time, indicated in miliseconds. Attach this to your show leds tile by dragging and dropping it directly below the tile as indicated, and change the numerical figure to 500 in order to program a half-second (500 millisecond) pause.

 

BBC micro:bit

 

  • Until you tell the program what to do after the one second pause, nothing will happen. So find the tile entitled 'clear screen' in the basic commands menu, and attach this beneath the pause (ms) block. Then attach another pause (ms) block beneath this and change the figure to 500 milliseconds to keep the heart switched off for a little longer..

 

  • Finally, find a 'forever' tile in the basic commands menu and wrap it around your blocks of code like so:

 

Flashing heart 3.jpg

 

  • Click 'run' now and the animated BBC micro:bit should show the heart flashing on and off at half-second intervals on a constant loop. Congratulations, you've created your first script!

 

  • To download your script to your BBC micro:bit, simply click 'compile' and your code will be downloaded as a .hex file.

 

  • If you haven't already, ensure your BBC micro:bit is connected to your computer using the USB connector. It will automatically show up under 'devices' as a USB device. Simply drag and drop the .hex file onto this device. An amber light on the back of the BBC micro:bit device should begin flashing. When this stops, the program is loaded and you can safely disconnect the BBC micro:bit from your computer.

 

  • Finally, re-connect your battery pack to the BBC micro:bit and press the 'reset' button on the device to run your program.

 

Have you tried this project at home or in the classroom? Once you've mastered the flashing heart, why not try experimenting with the featured commands to create more complex flashing loops, or to experiment with other shapes and patterns? Let us know how you get on in the comments section below...