Learning MicroPython on the BBC Micro:bit is one of the most rewarding ways for students to begin their programming and electronics journey. The BBC Micro:bit is a pocket-sized computer specifically designed for education — it has an LED matrix display, motion sensor, temperature sensor, and Bluetooth, all on a single board. MicroPython brings the simplicity of Python to this hardware, making it accessible to students who’ve learned Python in school. In India, Micro:bit is gaining traction in CBSE and ICSE schools that have adopted coding curricula under NEP 2020.
Table of Contents
- What is the BBC Micro:bit?
- Setting Up MicroPython on Micro:bit
- First MicroPython Programs
- Using Micro:bit’s Built-in Sensors
- Connecting External Sensors
- Micro:bit vs Arduino: Which for Beginners?
- Frequently Asked Questions
What is the BBC Micro:bit?
The BBC Micro:bit (version 2, released 2020) is a credit-card-sized computer developed by the BBC for educational use in the UK — it was distributed free to all Year 7 students (Class 7 equivalent) in the UK. Its built-in hardware makes it uniquely beginner-friendly:
- 5×5 LED matrix — displays text, numbers, patterns, and simple animations
- 2 programmable buttons (A and B)
- Built-in accelerometer/magnetometer — detects motion, tilt, and compass heading
- Built-in temperature sensor
- Built-in microphone and speaker (Micro:bit V2)
- Bluetooth and radio — for wireless communication between Micro:bits
- Edge connector — 25 GPIO pins (5 large, 20 small) for external hardware
Setting Up MicroPython on Micro:bit
Getting started with MicroPython on Micro:bit takes under 5 minutes:
- Connect Micro:bit to a computer via USB (micro USB cable)
- Go to python.microbit.org in Chrome or Edge browser
- This opens the MicroPython editor (browser-based, no installation needed)
- Write your Python code in the editor
- Click “Flash” — this uploads MicroPython firmware + your code to the Micro:bit automatically
- Watch your program run on the Micro:bit immediately
Alternative (offline): Download Mu Editor (free, all platforms) which provides a dedicated MicroPython IDE for Micro:bit with REPL, plotter, and file manager.
First MicroPython Programs
Program 1: Hello World — Scrolling Text
from microbit import *
# Scroll text across the LED matrix
while True:
display.scroll("Hello India!")
sleep(1000)
Program 2: Respond to Button Press
from microbit import *
# Show different responses to A and B buttons
while True:
if button_a.is_pressed():
display.show(Image.HAPPY)
sleep(500)
elif button_b.is_pressed():
display.show(Image.SAD)
sleep(500)
else:
display.show(Image.HEART)
sleep(100)
Program 3: Digital Dice
from microbit import *
import random
# Roll dice when Micro:bit is shaken
while True:
if accelerometer.was_gesture('shake'):
result = random.randint(1, 6)
display.show(str(result))
sleep(100)
Program 4: Temperature Display
from microbit import *
# Display temperature with heat indicator
while True:
temp = temperature() # Built-in temperature sensor
display.scroll(str(temp) + "C")
# Show warning if hot (relevant for Indian summers!)
if temp > 35:
display.show(Image.SKULL) # Too hot!
sleep(2000)
Using Micro:bit’s Built-in Sensors
Accelerometer (Motion Sensor)
from microbit import *
# Read tilt angles and display direction
while True:
x = accelerometer.get_x() # -1024 to +1024 mg
y = accelerometer.get_y()
if x 200:
display.show("R") # Tilted Right
elif y 200:
display.show("B") # Tilted Back
else:
display.show("O") # Level
sleep(100)
Compass (Magnetometer)
from microbit import *
# Simple compass
compass.calibrate() # Hold Micro:bit and tilt in all directions when prompted
while True:
heading = compass.heading()
if heading >= 315 or heading < 45:
display.show("N")
elif 45 <= heading < 135:
display.show("E")
elif 135 <= heading < 225:
display.show("S")
else:
display.show("W")
sleep(500)
Radio Communication (Multi Micro:bit)
import radio
from microbit import *
# Send and receive messages between two Micro:bits
radio.on()
radio.config(channel=42) # Both Micro:bits must use the same channel
while True:
if button_a.is_pressed():
radio.send("Hello from India!")
display.show(Image.YES)
message = radio.receive()
if message:
display.scroll(message)
sleep(100)
Connecting External Sensors
The Micro:bit’s edge connector (large pins P0, P1, P2 plus 3V and GND) allows connecting external sensors via crocodile clips or an edge connector breakout:
Simple LED Control
from microbit import *
# External LED on pin P0 (with 330 ohm resistor)
while True:
pin0.write_digital(1) # LED ON
sleep(500)
pin0.write_digital(0) # LED OFF
sleep(500)
Analog Sensor Reading (LDR)
from microbit import *
# Read LDR on pin P1 (via voltage divider circuit)
while True:
light_level = pin1.read_analog() # 0-1023
display.scroll(str(light_level))
if light_level < 200: # Dark
display.show(Image.ASLEEP)
else: # Bright
display.show(Image.HAPPY)
sleep(1000)
Micro:bit vs Arduino: Which for Beginners?
| Factor | BBC Micro:bit | Arduino Uno |
|---|---|---|
| Programming Language | MicroPython / Blocks | C++ / Blocks (mBlock) |
| Built-in sensors | Many (accel, temp, mic, speaker, BT) | None (add externally) |
| Initial project difficulty | Very easy (built-in display) | Easy-moderate (needs LED circuit) |
| Sensor expansion | Limited (few GPIO pins) | Extensive (14 digital + 6 analog) |
| India cost | ₹2,000–3,000 | ₹350–600 |
| Best for | Ages 9–14, first computer | Ages 12+, serious projects |
Frequently Asked Questions
Is MicroPython the same as standard Python?
MicroPython is a lean implementation of Python 3 designed for microcontrollers. Most Python 3 syntax works identically. However, some standard libraries are absent or reduced (no pandas, numpy, or full os module) because of memory constraints. The microbit Python module provides hardware-specific functions. Standard Python skills transfer about 90% to MicroPython.
Can BBC Micro:bit be used to teach CBSE Class 7 Computer Science?
Yes — the CBSE Class 7 CS curriculum includes basic programming concepts (sequence, loops, conditions) that map perfectly to Micro:bit MicroPython projects. Micro:bit’s visual LED feedback makes abstract programming concepts tangible for 12–13 year olds. Block-based coding (via MakeCode) is even simpler for initial introduction.
Where can I buy BBC Micro:bit in India?
Micro:bit is available from select electronics retailers in India, though availability is more limited than Arduino. Check online stores that import educational electronics. Prices typically range from ₹2,000–3,500 for the Micro:bit V2 Go bundle (includes USB cable and battery holder). Arduino Uno at ₹350–600 is a more cost-effective alternative for budget-conscious buyers.
What is the difference between Micro:bit V1 and V2?
Micro:bit V2 (2020 onwards) adds: built-in microphone, built-in speaker, touch logo (capacitive), more RAM (512KB vs 16KB), faster processor (64MHz Cortex-M4 vs 16MHz Cortex-M0). V2 is significantly more capable for audio projects. Both run MicroPython but V2 has additional hardware features accessible in code. In 2026, always buy V2.
Add comment