Session 1: Introduction to micro:bit
Goal: Get familiar with the micro:bit, learn basic programming, and create your first interactive programs.
What is a micro:bit?
The BBC micro:bit is a small, programmable computer with:
- LED display (5×5 grid)
- Two buttons (A and B)
- Built-in sensors (accelerometer, compass, temperature)
- GPIO pins for connecting external components
Getting Started
-
Access the Editor
- Go to makecode.microbit.org
- Click New Project and give it a name
-
Interface Overview
- Left: Simulator showing your micro:bit
- Middle: Block categories
- Right: Programming workspace
-
First Program: Hello World
- From Basic, drag
show stringinto theon startblock - Type “Hello!” in the text field
- Click the simulator to see it run
- Download to a real micro:bit (connect via USB)
- From Basic, drag
-
Interactive Program: Button Counter
- From Input, drag
on button A pressed - Inside it, add
show numberwith a variable - Use Variables to create a counter that increases each press
- Add button B to decrease the counter
- From Input, drag
-
Sensor Exploration
- Use the accelerometer to detect shaking
- Display different images when tilted left/right
- Show temperature readings on the LED display
🎯 Challenge: Dice Rolling Game
Create a game where you shake the micro:bit to “roll a dice” and display a random number from 1 to 6.
Hints:
- Use the
on shakeinput block - Use
pick random 1 to 6from the Math category - Display the result with
show number - Add a short animation before showing the result for fun!
Key Concepts You Learned
- What a micro:bit is and what it can do
- How to use the MakeCode editor
- Programming with blocks:
on start,forever,on button pressed,on shake - Using variables to keep track of values
- Displaying text, numbers, and icons on the LED grid
Think About It:
- What other programs could you make with just the built-in buttons and sensors?
- How might you use the micro:bit to solve a real-world problem?
- What happens if you combine multiple inputs (buttons + sensors)?