Getting Started with BBC micro:bit
Getting Started with BBC micro:bit
Connect your micro:bit, choose a language, and run your first program.
What is the BBC micro:bit?
The BBC micro:bit is a pocket-sized microcontroller designed for education, originally given to every Year 7 student in the UK in 2016. The current version (V2) packs an impressive set of built-in hardware:
- Nordic nRF52833 ARM Cortex-M4 processor at 64 MHz
- 512 KB Flash, 128 KB RAM
- 5G—5 LED matrix display
- 2 programmable buttons (A and B) plus a touch-sensitive logo
- Accelerometer and magnetometer (compass)
- Temperature sensor
- Microphone and speaker (V2 only)
- Bluetooth Low Energy and 2.4 GHz radio
- Edge connector with 25 pins (5 large, 20 small)
- USB and JST battery connector
Programming Options
The micro:bit supports several languages, all accessible from makecode.microbit.org or via the micro:bit Python Editor:
| Language | Best for | Editor |
|---|---|---|
| MakeCode Blocks | Absolute beginners, visual thinking | makecode.microbit.org |
| MakeCode JavaScript | Transition from blocks to code | makecode.microbit.org |
| MicroPython | Learners who prefer text coding | python.microbit.org |
| C++ (CODAL) | Advanced users / custom hardware | Mbed or PlatformIO |
This guide covers MicroPython ߀” ideal for students who have some Python experience.
Connecting the micro:bit
- Use a Micro-USB cable to connect the micro:bit to your computer
- The micro:bit appears as a USB drive named MICROBIT
- Open python.microbit.org in Chrome or Edge (or install the Mu editor)
Your First Python Program
from microbit import *
while True:
display.show(Image.HAPPY)
sleep(1000)
display.show(Image.SAD)
sleep(1000)
- Type the code into python.microbit.org
- Click Download ߀” a
.hexfile is saved - Drag and drop the
.hexfile onto the MICROBIT drive - The yellow LED flashes briefly during flashing, then your program runs
Alternative: Flash Directly with WebUSB
In Chrome/Edge, connect the micro:bit and click Connect in python.microbit.org. You can then click Flash directly without downloading a file.
The REPL (Serial Console)
The micro:bit has a serial REPL accessible at 115200 baud. In python.microbit.org, click the REPL tab. This lets you run Python commands interactively.
>>> from microbit import temperature
>>> temperature()
23
MakeCode Blocks Example
In MakeCode, the equivalent of the above Python in blocks is:
- on start: (nothing needed)
- forever: show icon ß™¥ ߆’ pause 1000 ms ߆’ show icon p?’€ ߆’ pause 1000 ms
MakeCode generates JavaScript and compiles it to the micro:bit automatically.
Powering the micro:bit
- USB ߀” power and program via your computer
- Battery pack ߀” 2G— AAA batteries in the JST connector (no USB needed)
- Edge connector 3 V pin ߀” power from an external 3 V regulated supply
The micro:bit runs at 3.3 V. All GPIO pins are 3.3 V only.
Important Pin Notes
The edge connector has 5 large "ring" pins:
| Pin | Function |
|---|---|
| 0 | GPIO / analog input / touch |
| 1 | GPIO / analog input / touch |
| 2 | GPIO / analog input / touch |
| 3V | 3.3 V power output |
| GND | Ground |
The smaller pins (3߀“22, plus SPI/I2C/UART) are accessible with an edge connector breakout board.