Coding Club
BBC micro:bit
Six projects for the BBC micro:bit, a tiny computer with 25 lights, two buttons, a speaker and sensors for movement, light and temperature. You write real Python in the free micro:bit Python Editor and try it in the simulator, then send it to a micro:bit and hold it in your hand.
Six days, six projects
One small project a session. Each one is a numbered list of steps with a picture of what to click and what you should see, then tests and stretch challenges for anyone who finishes early.
Get set up before day 1
You will need
- A computer with Chrome or Edge (for sending programs to the micro:bit)
- A micro:bit (V2 is best) and a USB data cable, one per pair
- No micro:bit? The editor's simulator runs every project
- No account needed
Setup step 1: Open the micro:bit Python Editor
Open Chrome or Edge and go to python.microbit.org. It is free and needs no account. It opens with a short program already written, which shows a heart and then scrolls the word Hello.
Your code goes in the middle. Down the left are Reference, Ideas and API, which are full of examples to copy, and on the right is a simulated micro:bit.
ReferenceIdeasAPIProjectMy project1# Imports go at the top2from microbit import *3 4 5# Code in a 'while True:' loop repeats forever6while True:7 display.show(Image.HEART)8 sleep(1000)9 display.scroll('Hello')Send to micro:bitSaveOpen…SimulatorThe editor: tabs on the left, your code in the middle, the simulator on the right. Setup step 2: Try the simulator
Press the simulator's play button. It runs the program in the editor, exactly as a real micro:bit would. You can press its A and B buttons with the mouse, and the controls under it can shake it, warm it up or shine a light on it. Press the button again to stop.
ReferenceIdeasAPIProjectMy project1# Imports go at the top2from microbit import *3 4 5# Code in a 'while True:' loop repeats forever6while True:7 display.show(Image.HEART)8 sleep(1000)9 display.scroll('Hello')Send to micro:bitSaveOpen…SimulatorPress play, and the simulated micro:bit shows a heart. Setup step 3: Plug in your micro:bit
Connect your micro:bit to the computer with its USB cable. A small yellow light on the back comes on. The cable must be a data cable: some phone charging cables only carry power, and then the computer never sees the micro:bit.
Setup step 4: Send a program to it
Click Send to micro:bit. The first time, the editor shows you how to connect: choose your micro:bit in the box that pops up and click Connect. A few seconds later the program is running on your real micro:bit, and it stays there, even after you unplug it.
ReferenceIdeasAPIProjectMy project1# Imports go at the top2from microbit import *3 4 5# Code in a 'while True:' loop repeats forever6while True:7 display.show(Image.HEART)8 sleep(1000)9 display.scroll('Hello')Send to micro:bitSaveOpen…SimulatorSend to micro:bit puts the program onto your real micro:bit. Watch out Sending this way needs Chrome or Edge. In any other browser, click Save, which saves a .hex file, then drag that file onto the MICROBIT drive, just like copying to a USB stick.Setup step 5: Name and save your project
Click the project name at the top to rename it. Save downloads your project as a .hex file, which you can open again next time with Open…. The editor also keeps your latest work in the browser.
ReferenceIdeasAPIProjectMy project1# Imports go at the top2from microbit import *3 4 5# Code in a 'while True:' loop repeats forever6while True:7 display.show(Image.HEART)8 sleep(1000)9 display.scroll('Hello')Send to micro:bitSaveOpen…SimulatorRename the project, then Save keeps a copy you can open again.
Notes for the teacher
Before the first session
- Open python.microbit.org on a club computer in Chrome or Edge, to check it is not blocked by the school's filter. Sending straight to a micro:bit needs one of these two browsers.
- Check each micro:bit's USB cable carries data: plug it in and look for a MICROBIT drive.
- A micro:bit V2 is best: it has a speaker, a microphone and a touch logo. A V1 does everything except the sounds and day 2's logo, which have notes saying what to do instead.
- No micro:bits at all? Every project works in the editor's simulator.
How the six projects build up
Day 1 is sequence and loops, day 2 selection with the buttons, day 3 random numbers and lists, day 4 sound and a sensor, day 5 more sensors and comparisons, and day 6 puts it all together in a game.