Your first program with Code
Code is where you write programs for the BBC micro:bit. Let's make one.
1. Open Code
From the Dashboard, click the Code tile. You'll see a chat on the left and a blocks area on the right.
2. Describe what you want
Type a request in the box at the bottom and press Enter (or click the send arrow). Try:
Show a smiley face on the screen
You don't need technical words. Describe it the way you'd explain it to a friend.
3. Watch the program appear
MicroChat writes the code and shows it as MakeCode blocks on the right. Click the JavaScript tab to see the same program as text, and Code Blocks to switch back.
MicroChat will also ask you a question, such as "What do you think will happen when this runs?" This is part of how it teaches — have a guess, then find out.
4. Run it on a micro:bit
Plug in a micro:bit with a USB cable and click Download. The first time, your browser asks you to choose the micro:bit — pick it and click Connect. The program runs on the micro:bit a few seconds later.
See Connecting and flashing your micro:bit if anything gets in the way.
5. Change it
Just keep chatting:
Make it show a sad face when I press button B
MicroChat updates the program and the blocks change to match.
Useful buttons
- Explain – MicroChat explains the current program in simple terms.
- Copy – copies the JavaScript to your clipboard.
- MakeCode – opens the program in the full MakeCode editor. See Editing in MakeCode.
- Download – sends the program to your micro:bit.
- The + button next to "Code" in the top bar starts a fresh program.
Using Forward Education kits
Tick Forward Education extension under the chat box before you ask, and MicroChat can use the sensors and motors from Forward Education's kits. See Using Forward Education kits.
Tips for good requests
- One idea at a time works best. Build up step by step.
- Say which buttons or sensors you want to use if it matters.
- If something isn't right, tell MicroChat what you expected instead. It will fix it.