Beginner Micro:bit
CADDigital LiteracyComputing Systems

Beginner Micro:bit

Grades 3–12
5 hrs
10 steps
Groups of 20
NC SCOS

Standards Alignment

NC SCOS

Computer Science

  • HS-AP-03: Evaluate algorithms in terms of their efficiency, correctness, and clarity.
  • 68-AP-03: Design and iteratively develop programs that combine control structures including nested loops and compound conditionals.
  • 35-AP-03: Construct programs that include sequences.
  • 35-AP-04: Construct programs using simple loops.
  • 68-AP-04: Construct programs that include events.
  • 35-CS-02: Model how computer hardware and software work together as a system to accomplish tasks.
  • 35-AP-05: Construct programs that implement conditionals.
  • 68-AP-01: Implement flowcharts and/or pseudocode to address complex problems as algorithms.
  • 35-AP-02: Create programs that use variables to store and modify data.
  • 68-CS-02: Design projects that combine hardware and software components to collect and exchange data.
  • 68-AP-07: Create procedures with parameters to organize code and make it easier to reuse groups of instructions.
  • 68-DA-02: Collect data using computational tools.

Showing 12 of 14 standards.

Lesson Steps

1

Beating Heart

30 min

Step 1: Make it

 

What is it?

Make your micro:bit’s heart beat using loops to create an animation.

These two videos show you what you'll make and how to code it:

 

Introduction

 

 

Coding guide

 

 

How it works

  • The program shows a beating heart using two built-in pictures, a large and small heart, on the micro:bit's LED display.
  • Different images shown in a sequence create the illusion of movement: a heart getting larger and smaller.
  • After showing each image, the program pauses for half a second (500 milliseconds) before showing the next image.
  • The animation is kept going forever using an infinite loop: it repeats the sequence of showing these two images and pausing until you unplug the micro:bit.
  • Using loops to keep things happening is an important idea in computer programming: we have created an animation that will keep running for as long as the micro:bit has power using only a small amount of code. This is also called iteration.

 

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

 

 

Step 2: Code it

 

MakeCode

 

 

 

Python

 

1from microbit import *
2
3while True:
4    display.show(Image.HEART)
5    sleep(500)
6    display.show(Image.HEART_SMALL)
7    sleep(500)
8
9

 

 

Open in Classroom

Open in MakeCode

Download HEX

Open in Python

 

Step 3: Improve it

  • Make the heart beat faster or slower by changing the delay time.
  • Try animating other built-in images like the small and large diamond or square.
  • Create your own animations using your own designs.
2

Animated Animals

30 min

Step 1: Make it

 

What is it?

Animate your own pictures on the micro:bit display.

 

duck image moving up and down on the micro:bit LED display

 

 

How it works

  • This program creates an animation on the micro:bit’s LED display output by using a built-in image and one you create yourself.
  • First it shows the duck built-in image and then shows a modified version, which is made by moving all the dots (pixels) down one row.
  • It shows the two different pictures one after the other, with a half second (500 millisecond) delay, to make it look like a duck bobbing up and down on the water.
  • An infinite loop keeps the micro:bit showing the image sequence until you unplug the micro:bit.
  • Using loops in computer programmes is also known as iteration. They help you create efficient compact code without needlessly repeating the same instructions.

 

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • optional graph paper or LED planning sheet to sketch out your own animal designs

 

Step 2: Code it

 

MakeCode

 

 

Python

 

1from microbit import *
2
3while True:
4    display.show(Image.DUCK)
5    sleep(500)
6    display.show(Image(
7        "00000:"
8        "09900:"
9        "99900:"
10        "09999:"
11        "09990"))
12    sleep(500)

 

 

Open in Classroom

Open in MakeCode

Download HEX

Open in Python

 

 

Step 3: Improve it

  • Try modifying and animating different built-in images like GIRAFFE and RABBIT.
  • Create your own images from scratch using graph paper or our LED planning sheet to sketch out your designs.
  • Make longer animated sequences to tell a story.
  • In Python, use different numbers to change the brightness of different pixels. 9 is the brightest, 1 is the dimmest and 0 is off.

 

3

Sunlight Sensor

30 min

Step 1: Make it

 

What is it?

Turn the LED display into a sensor to make your micro:bit react to light.

 

micro:bit reacting to sunlight falling on it by showing a sun icon on its LED display

 

How it works

  • As well as working as an output, the LEDs on your micro:bit can also work as an input device light sensor, measuring the amount of light falling on them.
  • This means that micro:bit programs can make different things happen depending on how light or dark it is.
  • The program uses an ‘if… else’ statement to show the sun image only if the light level is greater than (>) a certain level. This is known as selection – selecting when different things happen.
  • Flash this program onto your micro:bit and shine a light source, like a torch, daylight or bright ceiling light on to the micro:bit, and you should see the sun appear.
  • Cover the micro:bit with your hand and the sun icon should vanish.
  • If it doesn’t work, try making the 100 number smaller to suit the lighting where you are.
  • You can read more background information about how the micro:bit light sensor works here.

 

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • a light source and something to cover the micro:bit with – your hand will do!

 

Step 2: Code it

 

MakeCode

 

 

Python

 

1from microbit import *
2
3while True:
4    if display.read_light_level() > 100:
5        display.show(Image(
6        "90909:"
7        "09990:"
8        "99999:"
9        "09990:"
10        "90909"))
11    else:
12        display.clear()

 

 

Open in Python

Open in Classroom

Open in MakeCode

Download HEX

 

Step 3: Improve it

  • Show a different picture, like a moon or star, when it’s dark.
  • Show an animated sun when light falls on your micro:bit.
  • Turn this project into a night-light by making it light up the micro:bit’s display when it goes dark.
4

Magic 8-ball

30 min

Step 1: Make it

 

What is it?

Recreate a classic toy from the 1950s with your micro:bit and customise it to make it your own.

 

micro:bit being shaken and showing a tick on its LED display next to a magic 8 ball toy

 

How it works

  • A Magic 8-ball is a toy invented in the USA in the 1950s. Shaped like an oversized pool ball, you ask it a question like ‘will I be rich and famous one day?’, shake the ball and one of 20 different answers randomly appear in a window. Answers can be positive, negative - or somewhere in between.
  • This program recreates a Magic 8-ball using the micro:bit’s accelerometer, its ability to make random numbers and its LED display output to show a tick for yes, a cross for no or a ‘meh’ face for ‘not sure’.
  • The program generates a random number between 1 and 3 then uses if… then… else… if… statements to make different symbols appear depending on the number. This is known as selection.
  • If the number is 3, it shows a tick for ‘yes’. If the number is 2, it shows a cross for ‘no’.
  • The program doesn’t need to check if the number is 1, because if it’s not 3 or 2, it must be 1, in which case it shows a ‘meh’ face for ‘not sure.’

 

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • some questions to ask your micro:bit

 

Step 2: Code it

 

MakeCode

 

 

Python

 

1from microbit import *
2import random
3
4while True:
5    if accelerometer.was_gesture('shake'):
6        number = random.randint(1, 3)
7        if number == 3:
8            display.show(Image.YES)
9        elif number == 2:
10            display.show(Image.NO)
11        else:
12            display.show(Image.MEH)

 

 

Open in Classroom

Open in MakeCode

Download HEX

 

Open in Python

 

Step 3: Improve it

  • Make the image vanish after a few seconds.
  • Make the micro:bit show different cryptic answers when you shake it, instead of pictures. It could say ‘I am not sure’ or ‘That remains to be seen’.
  • Here’s another way of making a Magic 8-ball using Python.
5

Step Counter

30 min

Step 1: Make it

 

What is it?

Turn your BBC micro:bit into a step counter (or pedometer) to help you track how active you are - and learn some coding at the same time!

These two videos show you what you'll make and how to code it:

 

Introduction

 

 

Coding guide

 

 

How it works

  • Download the code onto a micro:bit and attach a battery pack.
  • Attach the micro:bit and battery pack to your shoe or ankle, place it inside your sock, or just hold it in your hand and shake it as you walk.
  • The code uses the micro:bit’s accelerometer sensor input to sense when your leg is moving.
  • The code counts how many times the micro:bit has been shaken. It stores this number in a variable called ‘steps’.
  • Variables are containers for storing data, which can be accessed and updated while a program is running.
  • Every time the micro:bit accelerometer input senses a shake, the program increases the number held in the variable by 1, and shows the new number on the LED display output.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack
  • something to attach the micro:bit to your shoe or leg – elastic band, a pipe cleaner, tape or Velcro.

 

Step 2: Code it

 

MakeCode

 

 

Python

 

1from microbit import *
2steps=0
3
4while True:
5    if accelerometer.was_gesture('shake'):
6        steps += 1
7        display.show(steps)

 

 

Open in Classroom

Open in MakeCode

Download HEX

Open in Python

 

Step 3: Improve it

  • Modify the code so it shows your current step count when you press a button.
  • If you find that the code only counts every other step, modify the code to multiply the ‘steps’ variable by two when it’s displayed.
  • Measure the length of your average stride and get your micro:bit to multiply this by the number of steps to calculate the distance you’ve walked.

 

girl pointing at micro:bit step counter on another girl's shoe

6

Scratch Boom Box

30 min

Step 1: Make it

 

What is it?

Make your own sound machine using the micro:bit’s buttons and accelerometer.

 

Scratch boom-box sprite

 

How it works

  • Like the Scratch theremin project this uses the accelerometer to measure the angle of tilt to make sounds lower and higher in pitch.
  • Instead of using a ‘forever’ loop to play a constant sound, this project plays two different beatbox sounds on your computer’s audio output when you press micro:bit input button A or button B.

 

What you need

  • micro:bit and optional battery pack
  • a suitable computer with Scratch link installed. See https://scratch.mit.edu/microbit for details on how to get Scratch working with micro:bit

 

Step 2: Code it

 

Scratch

 

Scratch blocks to make boom-box work

 

Open in Scratch

Download project

 

 

Step 3: Improve it

  • Change the boom-box sounds or add others from Scratch’s sound library.
  • Record your own sounds, trigger them with button presses and change their pitch by tilting.
  • Use sequences of notes to play different tunes when you press different buttons.
7

Thermometer

30 min

Step 1: Make it

 

What is it?

Show how hot or cold your micro:bit is using the built-in temperature sensor.

 

micro:bit showing number 9 next to a thermometer icon

 

How it works

  • This program shows how hot or cold your micro:bit is by taking a reading from the temperature sensor in its processor or CPU (central processing unit).
  • The processor’s temperature is a fairly good approximation of the temperature around you in °C (Celsius).
  • In this program, when you press input button A, the micro:bit displays the processor’s current temperature on its LED display output.
  • Take the micro:bit into warmer and colder places and see how the temperature readings change.

 

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • a source of heat or cooling, like a fan, if you want to see the temperature change quickly (optional)

 

Step 2: Code it

Python

 

1from microbit import *
2
3while True:
4    if button_a.was_pressed():
5        display.scroll(temperature())
6

 

MakeCode

 

 

 

Open in MakeCode

Open in Classroom

Open in Python

Download HEX

 

 

Step 3: Improve it

  • Compare the reading with another thermometer. How accurate is the micro:bit? Do you need to modify the micro:bit reading to get the air temperature?
  • Convert the temperature to Fahrenheit or Kelvin.
  • Use radio to make a remote sensor sending temperature readings to another micro:bit, for example from outside to inside. You could make an indoor / outdoor thermometer this way.
8

Saving Sea Turtles

30 min

Step 1: Make it

 

What is it?

Newly-hatched sea turtles use moonlight to find their way to the sea. Tall, bright lights can confuse them. Build a prototype of beach lighting for paths that guides humans safely but doesn't distract turtles.

This project is part of a series created to offer problem-solving and prototyping activities designed to explore technology as a solution to the challenges of the Global Goals for Sustainable Development.

 

Introduction

 

 

Coding guide

 

 

 

What you'll learn

  • How to make a prototype for a larger project
  • How computers take readings from inputs, process the data to make different outputs depending on the value of sensor readings

 

How it works

  • This project uses the micro:bit’s LEDs as a light sensor input. Cover the display with your hand and it should light up with the turtle picture.
  • It could be used at ground level to guide humans along a beach path at night, without confusing sea turtle hatchlings with tall, bright lights that they may mistake for the moon.
  • The program uses selection to sense if the light falling on the micro:bit falls below a certain level, if it is less than (<) 100. If it is dark, it lights up the micro:bit display, else it clears the screen so the LEDs are dark.
  • You may need to adjust the threshold number 100 depending on the lighting conditions where you are. If you're in a very bright place, you may need a smaller number.

 

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

 

 

Step 2: Code it

MakeCode

 

 

Python

 

1from microbit import *
2
3while True:
4    if display.read_light_level() < 100:
5        display.show(Image(
6        "00000:"
7        "09900:"
8        "99999:"
9        "99999:"
10        "90090"))
11    else:
12        display.clear()
13    sleep(2000)

 

Open in Python

Open in Classroom

Open in MakeCode

Download HEX

 

Step 3: Improve it

  • Create your own picture to show on the LED display
  • Add an animation
  • Change the display to show arrows to make sure people walk on the correct side of the path

 

9

Disco Lights

30 min

Step 1: Make it

 

What is it?

Make your own disco light show with the new micro:bit! The LED lights pulse in time to music picked up by the built-in microphone. The louder the sounds, the brighter they glow.

 

Introduction

 

Coding guide

 

What you'll learn

  • How to use the new micro:bit's built-in microphone sensor to measure how loud a sound is
  • How to vary the brightness of the LED display output in response to sensor input readings

 

How it works

  • The microphone measures loudness of the sounds it picks up as numbers from 0-255. 0 is the quietest sound, 255 is the loudest.
  • All the LEDs on the display are switched on when the program starts.
  • The brightness of the LEDs can also be set using numbers from 0-255. 0 is the darkest (off) and 255 is the brightest.
  • A loop constantly sets the brightness of LEDs to match the amount of sound picked up by the microphone sensor.
  • The louder the sound, the brighter it makes the LEDs shine.
  • Flash this program on to a new micro:bit with sound, play some music with a strong beat and watch the lights pulse in time to the music!

 

What you need

  • new micro:bit with sound (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

 

Step 2: Code it

 

MakeCode

 

Python

from microbit import *
2
3lights = Image("11111:"
4              "11111:"
5              "11111:"
6              "11111:"
7              "11111")
8
9while True:
10    display.show(lights * microphone.sound_level())

 

Open in Python

Open in Classroom

Open in MakeCode

Download HEX

 

Step 3: Improve it

  • Modify the program to use your own images or patterns
  • If you're in a class or group, flash the program on to multiple micro:bits, dim the lights, play some music and have a light show!
  • Can you make the lights get darker with louder sounds?
10

Clap Lights

30 min

Step 1: Make it

 

What is it?

Turn your micro:bit into a light that you can turn on and off by clapping or making any loud sound.

 

Introduction

 

Coding guide

 

What you'll learn

  • How to switch outputs in response to sensor inputs
  • How to use Boolean logic to make a switch that toggles on and off when triggered by the same event

 

How it works

  • The program uses a variable called lightsOn to keep track of the light's status: whether it's switched on or off. We're using it as a special kind of variable, a Boolean variable. Boolean variables can only have two values: true (on) or false (off).
  • When the microphone sensor detects a loud sound, the code toggles the value of lightsOn by setting it to be not lightsOn.
  • This means that when you clap, if lightsOn is false (and the lights are off), it becomes true and the program lights the LEDs.
  • If lightsOn was true (and the lights were on), it becomes false and the code switches the LEDs off by clearing the screen.

 

What you need

  • A micro:bit
  • MakeCode or Python editor
  • battery pack (optional)

 

Step 2: Code it

 

MakeCode

 

Python

from microbit import *
2lightsOn = False
3
4while True:
5    if microphone.was_event(SoundEvent.LOUD):
6        lightsOn = not lightsOn
7        if lightsOn:
8            display.show(Image('99999:'
9                               '99999:'
10                               '99999:'
11                               '99999:'
12                               '99999'))
13        else:
14            display.clear()
15    sleep(100)

 

Open in Python

Open in Classroom

Open in MakeCode

Download HEX

 

Step 3: Improve it

  • You can make the 'on loud sound' block more or less sensitive by adding a 'set loud sound threshold' block to an ‘on start’ block. Use smaller numbers for quieter sounds, larger numbers for louder sounds. The coding video above shows you how to do this.
  • In Python, to change the threshold for loud sounds use microphone.set_threshold(SoundEvent.LOUD, 128) - changing the number 128 to the value you want between 0 and 255.
  • Make the lights also play a tune when they turn on.
  • Use sound to control other projects, such as lighting LEDs or servo motors connected to the pins on your micro:bit.

Materials

  • Micro:bit Club Pack (10x) — 2 per classroom

Related Supply Kit

Micro:bit Pack

All the hands-on materials you need for this lesson, delivered to your classroom.

More robotics lessons

Ready to bring this lesson to your classroom?

Sign up to save this lesson, order supplies, and track student progress.