This is a collection of tutorial information for the Micro:bit, which is a half-credit card sized device developed by the BBC in the United Kingdom for computer education. It continues to be used by millions of students world-wide. It has a wide range of built-in and add-on sensors, and can be programmed online through Microsoft MakeCode, MicroPython, Scratch, or a host of other options.
Micro:bits have a low floor (easy to get started), a high ceiling (you can do advanced work), and wide walls (widely applicable) MIT's Mitch Resnick. Micro:bits are an example of Physical Computing where what the computer does is not just behind a screen, but out in the real world.
This material is designed to help you get started, point you in the direction of helpful resources, and to inspire you to consider how you might use Micro:bits in your own third grade through college-level instruction.
See the Where to Buy page if you don't already have a microbit. You want to get version 2, which can be identified by the notched bottom edge connector. (This tutorial modified from Dan Law and Jeff Solin’s and Dale Reed’s.)
Take a look at the different components on the physical device. Do not plug it into your computer yet!
Front and Back of Micro:bit
You want version 2 with a notched bottom edge connector.
Front:
On the front there is a grid of red LED's used to display patterns and scrolling text, and can also be used to detect light. The A and B Buttons as well as the Touch Logo can be used to trigger actions. The Mic can sense sound levels. The metallic bottom Edge Connectors are used to connect external devices such as other sensors, screens, or motors.
Back:
The top-middle is the Micro-USB cable connector where you connect your Micro:bit to a computer. The cable provides power and allows downloading programs from your computer onto your device. To the right of that is the Reset and Power Button and then an external battery connection so that after downloading a program you can disconnect your device from the computer and move around with it. On the top-left is the Radio Antenna used for Bluetooth radio communication with other Micro:bits. Near the center is a Speaker that can play different musical beeps and tones. Near the bottom-left is the Motion Sensor (accelerometer) and Compass direction sensor. Near the middle-left is the processor which is also a Temperature Sensor.
(If interested see further overview descriptions of each sensor, as well as hardware technical details.)
We'll be mostly using the browser-based makecode.microbit.org blocks programming environment to create our programs, along with a bit of Python. Select that makecode link and open it now, choosing the purple plus sign to make a new project, as shown at right.
Within this new project select which color drawer category you want, and within that select which block you want, dragging it to the right over into the program area. You will see the results running in the simulator at the left of the MakeCode window.
Use this interface...
... to make this
Experiment with different blocks and with the different options below the simulator. To delete a block drag it out of the program pane and release it.
Change your program to use the "show string" command to display some message (e.g. "Hi"). The quotes are automatically supplied for you.
Give your program a name (e.g. "First Program") and select the purple Download button or the save icon. This will create a hex file in your Downloads folder on your computer.
Now use the micro USB cable to connect your Micro:bit to your computer. Your Micro:bit should show up as a USB device on your computer, similar to an external drive.
The next step varies between operating systems, but the goal is to drag-and-drop your newly-created hex file from your Downloads folder onto your Micro:bit device. For instance on a Mac, a program named First Program gets stored as microbit-First-Program.hex in the Downloads folder, and dragging it onto your Micro:bit looks like this:
Downloading and then dragging your program each time is not necessary. You can connect your programming environment directly to your device by choosing the three-dot meatball menu just to the right of the purple Download button, and selecting "Connect device" and then follow the prompts. After doing so, changes to your program get flashed to your device each time when you select Download without you having to drag-and-drop the file.
Select the purple LED drawer to find the purple blocks. Create the blocks program shown below. Run it in the simulator and then on your device.
Wonder: What does it do? Compare with your partner. What is the difference between the "on start" and the "forever" blocks? What happens if you change the x,y values in the purple LED blocks? Can you figure out the range of valid values for x and y?
Create and run this program using the on start block.
Now use a forever block instead, and run it again.
What is the difference between these two blocks?
Select the Pink Input drawer and pull out a "on button A pressed" block. Notice how you can right click on blocks to duplicate them, or use the keyboard shortcuts to copy/paste. You can also add a comment.
Select the blue Basic drawer "show leds" block and create the program shown at right. Test it in the simulator and then on your device.
Wonder: What different input could you use to display an up arrow? Is there yet some distinct input you could use to display a down arrow?
From the pink Input drawer pull out the "on shake" block. Place into it one of the Music drawer blocks.
Test in the simulator and then on your device.
Wonder: What other kinds of sounds could you use? What other sorts of motions besides shake are available from the drop down menu? Can you have different motions cause different effects? (Hint: You have to tip it almost 90 degrees.)
From the pink Input drawer pull out the "on loud sound" block and use one of the blue blocks to have it show some icon. Since the simulator can't actually hear sound (or feel motion or a button press), the simulator gives us other ways to indicate that input. The sound sensor value goes from 0 to 255. The "loud" sensor gets triggered when the value goes from low to above 165.
Test in the simulator and then on your device.
Wonder: Can you discover what the threshold value is for a "quiet" sound? Can you find the block used to set the sound threshold values?
Combine the forever block, the blue drawer "show string" block, and "light level" from the pink Input drawer. Drag the simulator upper-left corner light image up and down to vary the light sensor value from 0 to 255.
Test in the simulator and then on your device.
Wonder: How can you alternatively (from the Input drawer) trigger temperature, compass heading, and acceleration values on your physical device? Can you figure out how to use the Math drawer to convert all values into the 1 to10 range?
Alligator clips or a wire can be used to complete the circuit between pin 0 on one end and GND (Ground) on the other.
Once the circuit is completed by touching the alligator clips together, the LED pattern is displayed. You can also use play-doh, aluminum foil, or a piece of fruit as parts of completing the circuit.
Wonder: Can you use your fingers? A paperclip? Using alligator clips, can pencil lead on a piece of paper complete the circuit? How might you make a "switch" that activates the circuit when two surfaces come together, such as when a door closes or opens?
For this activity you need two people, A and B, each with their own Micro:bit. Create the program below using the lavender Radio drawer blocks. Be careful -- there are multiple versions of the "on radio received" block! You will need two physical devices to test this.
Wonder: What happens if you and your partner use different radio group numbers? What happens if multiple sets of partners all use the same radio group number? Can you assign pre-set buttons with text to be sent, such as "Yes" and "No"? How far away can you and your partner be? Does it work around a corner? Outside? Through glass?
Person A makes this version,
sending "Base to Agent"
Person B makes this version, identical except for the message.
To help you brainstorm, in the MakeCode programming environment first explore the various different drawers we haven't used yet. Near the bottom check out the Extensions and the Advanced drawers. Also browse through the Resources page on this site.
Think back on the examples we've explored, getting input using buttons, movement, light, temperature, compass heading, and radio messages, along with getting feedback using LEDs, sound, and responses to radio messages.
Individually brainstorm and write down different types of applications where a Micro:bit might be a component. Use your imagination, and since we're brainstorming, don't edit yourself! What sorts of problems exist where a Micro:bit might be part of a solution? What other sorts of connections, sensors, or devices might be needed?
After brainstorming individually for several minutes, compare notes with a partner. Together choose a couple of ideas that you would like to share out to the larger group.
What ideas would work best in your context?
If you are running a class or a lab using micro:bits, if the micro:bits are new they may have the out-of-the-box experience on them, which goes through a sequence to introduce a new user to micro:bit features. To erase all programs, see these instructions.