Micro:bitMakeCodeExplorersFirst steps

Name badge: your name in lights

Your very first program. Your name scrolls across the 25 lights, each button shows a face, a heart beats, and a shake shows a secret. Nothing to wire: only the Micro:bit. At the end you wear it home on a battery pack.

QR code to this pageScan to open

What you learn

8 things on the Explorers, the very first steps: the Micro:bit alone and MakeCode blocks, nothing to wire path: open to see them

On the learning path: Explorers, the very first steps: the Micro:bit alone and MakeCode blocks, nothing to wire

Programming

  • Make a program with blocks and download it to your own Micro:bit
  • Steps run one after the other: first your name, then a face
  • Buttons A, B and A+B each start their own blocks from story 2
  • Pictures that change over time make an animation from story 3

Electronics

  • The Micro:bit feels a shake: no extra part needed from story 4

Thinking and making

  • Try it in the simulator, then on the real Micro:bit
  • Nothing happens? Check the block, the download and the batteries, one at a time

AI in the loop

  • Your name, your faces, your secret: the design is yours

1See it in action

On screen: the name SAM scrolls across the Micro:bit's lights, a smile appears, then a heart beats big and small
Your name, then a beating heart story 3, on screen
A Micro:bit on a blue string, worn as a badge, with a red heart on its lights
Wear it on a string, with a battery pack

2Parts you need

Micro:bit V2 and a USB cable
Battery pack with ON/OFF switch (to wear it)from story 4

And: a computer with Chrome or Edge, and for wearing it a string or a lanyard and some tape. That is all: no wires, no breadboard.

3Learn the basics

Read these before you start, or come back when you need them.

012 3VGND rings for crocodile clips logo: touch it buttonA buttonB

Meet the Micro:bit

The Micro:bit is a small computer that you program yourself. On the front: 25 red lights (the screen), button A and button B, and a logo you can touch. Inside: a shake sensor, a speaker, a microphone and a compass. At the bottom: rings for crocodile clips.

It does nothing until you give it a program: you make it in MakeCode and download it.

More: get your program onto the Micro:bit
  1. Open MakeCode (makecode.microbit.org) in Chrome or Edge and make your program with blocks. The Micro:bit on the left of the screen (the simulator) shows what it will do.
  2. Connect the real Micro:bit with the USB cable. A small yellow light on the back comes on.
  3. Press Download. The first time, choose Connect and pick your Micro:bit (BBC micro:bit).
  4. The yellow light flashes while the program goes over, then your program starts by itself.
  5. Test it on the real Micro:bit. To start it again from the beginning, press the reset button on the back.

Without the cable: a battery pack (2 × AAA) in the white socket on the back. The program stays on the Micro:bit until you download a new one.

Real MakeCode blocks: on button A pressed shows a smile, forever shows a big and a small heart again and again, on start shows the name SAM once

Blocks: when does my program run?

In MakeCode you drag blocks from the colourful list and snap them together. The outer block decides when the blocks inside run: on start runs them once, when the Micro:bit starts. forever runs them again and again. on button A pressed runs them every time something happens: that is an event.

Inside a block, the steps run from top to bottom, one after the other.

More: tips for your first program
  • A block must click in. A grey, loose block does nothing: drag it until it snaps into place.
  • Find blocks by colour. Basic (blue) shows things, Input (pink) has the buttons and shake, Music (red) plays sounds.
  • Try it first on the screen. The simulator on the left runs your program: click A and B there.
  • Undo with the arrow at the bottom, or press Ctrl and Z.
  • Text in quotes. Click in the white field of show string and type your own words.
The Micro:bit board

Motion sensor (accelerometer)

The Micro:bit has a small chip that feels movement and which way is down. It notices a shake, a tilt to the left or right, and the board lying face up or down.

Events like "on shake" for quick moves; "acceleration (mg)" for how far it is tilted.

More: the numbers

acceleration (mg) x is about 0 when the Micro:bit lies flat, and goes to about −1000 and +1000 when you tilt it fully left or right (mg means thousandths of the pull of the earth). strength adds all directions: a hard swing gives a big number.

The MakeCode blocks of this program
The same in Python
def on_gesture_shake():
    basic.show_icon(IconNames.SURPRISED)
input.on_gesture(Gesture.SHAKE, on_gesture_shake)

def on_forever():
    led.plot_bar_graph(abs(input.acceleration(Dimension.X)), 1023)
basic.forever(on_forever)

4Wear it

Left: the back of the Micro:bit with a battery pack of two AAA batteries plugged into the white socket and taped on. Right: the front with a string through the two outer rings, worn as a badge

Your program stays on the Micro:bit, also without the cable. Plug the battery pack into the white socket on the back, stick the pack on, and tie a string through the two outer rings. Slide the switch on the pack to OFF when you are done.

5Try it

The badge lab runs every story on screen. Type your name, press A, B or A+B, and drag the Micro:bit quickly to shake it.

Open the badge lab in a new tab

6Program it

You see the program for . Choose another story in the bar at the top of the page.

Your first time in MakeCode? Start here
  1. Open makecode.microbit.org in Chrome or Edge and press New Project. Give it a name, like badge.
  2. You see on start and forever. Find the blocks by their colour: Basic (blue) has show string and show icon, Input (pink) has the buttons and on shake.
  3. Drag each block until it clicks into place, like in the picture below. A grey block is not connected.
  4. Try it on the Micro:bit on the left of the screen, then connect your own Micro:bit and press Download (the Micro:bit card in Learn shows how).

Story 1: Put your name in lightsyour first program

The MakeCode blocks of story 1
The same in Python
# Story 1: Put your name in lights. Type your own name; it scrolls once, then a smile stays.
basic.show_string("SAM")
basic.show_icon(IconNames.HAPPY)

Put show string into on start and type your own name in the white field. Then add show icon with a smile. Download it: your name scrolls past once, then the smile stays.

Your turn: press the reset button on the back of the Micro:bit. What happens, and why?

You first

Your first program is yours: drag the blocks yourself, type your own name, and download it. Ask the person next to you before you ask anything else.

Story 2: A face for each buttonevents

The MakeCode blocks of story 2
The same in Python
# Story 2: A face for each button. Choose your own faces.
basic.show_string("SAM")
basic.show_icon(IconNames.HAPPY)

def on_button_pressed_a():
    basic.show_icon(IconNames.HAPPY)
input.on_button_pressed(Button.A, on_button_pressed_a)

def on_button_pressed_b():
    basic.show_icon(IconNames.SURPRISED)
input.on_button_pressed(Button.B, on_button_pressed_b)

Drag on button A pressed from Input onto the empty space, and put a face inside. Do the same for button B. These blocks wait: they run every time you press the button. Choose your own faces.

Your turn: which face shows how you feel today? Put it on button A.

Story 3: Make a heart beatanimation

The MakeCode blocks of story 3
The same in Python
# Story 3: Make a heart beat. Button B shows big, small, big, small; A and B together show your name again.
basic.show_string("SAM")
basic.show_icon(IconNames.HAPPY)

def on_button_pressed_a():
    basic.show_icon(IconNames.HAPPY)
input.on_button_pressed(Button.A, on_button_pressed_a)

def on_button_pressed_b():
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.SMALL_HEART)
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.SMALL_HEART)
    basic.show_icon(IconNames.HEART)
input.on_button_pressed(Button.B, on_button_pressed_b)

def on_button_pressed_ab():
    basic.show_string("SAM")
input.on_button_pressed(Button.AB, on_button_pressed_ab)

Button B now shows a big heart, a small heart, a big one, a small one: pictures that change quickly look like a heart that beats. Each show icon waits a little before the next. Press A and B together to see your name again.

Your turn: make the heart beat more times. Can you make it beat faster?

Real world

Smart watches and fitness bands show little pictures, hearts and numbers on a tiny screen, just like your badge: a program decides what to show and when.

Story 4: Shake for a secretthe shake sensor

The MakeCode blocks of story 4
The same in Python
# Story 4: Shake for a secret. Shake the badge: a secret picture and a giggle.
basic.show_string("SAM")
basic.show_icon(IconNames.HAPPY)

def on_button_pressed_a():
    basic.show_icon(IconNames.HAPPY)
input.on_button_pressed(Button.A, on_button_pressed_a)

def on_button_pressed_b():
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.SMALL_HEART)
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.SMALL_HEART)
    basic.show_icon(IconNames.HEART)
input.on_button_pressed(Button.B, on_button_pressed_b)

def on_button_pressed_ab():
    basic.show_string("SAM")
input.on_button_pressed(Button.AB, on_button_pressed_ab)

def on_gesture_shake():
    basic.show_icon(IconNames.GHOST)
    music.play(music.builtin_playable_sound_effect(soundExpression.giggle),
        music.PlaybackMode.UNTIL_DONE)
input.on_gesture(Gesture.SHAKE, on_gesture_shake)

The Micro:bit can feel when it moves. Drag on shake from Input and put a secret picture and a sound inside: the play giggle block is in Music. Only someone who shakes your badge finds the secret.

Your turn: show your badge to someone. Do they find the secret?

7Challenges

Four challenges: your own pictures drawn with show leds, button A for your name and B for your hobby, a sound for each button, and your own animation

Challenges

  • Your own pictures: use show leds and click the lights to draw your own picture.
  • Who is it? Button A shows your name, button B your hobby or your favourite animal.
  • Make it louder: play a different sound for each button (Music).

Explore further

  • Animate it: your own animation with four pictures or more: a rocket, rain, a dancing figure.
  • Touch the logo: on logo pressed (Input) shows one more secret.
  • For a friend: make a badge for someone else, with their name and their favourite picture.

8How others did it

Other kids made their badge their own way. Made yours your own way? Show your teacher.

Nothing here yet. Made it your own way? Show your teacher: it may end up here.

9Check what you learned

Before you leave. Your teacher picks some of these for you: answer out loud, draw on paper, or work with the person next to you. Some cards change with your story: now .

Answer it

Tap an answer: you see at once if it is right, and why

  1. Your name scrolls past once and then a smile stays. Why only once?

  2. Put the steps in order to get your program onto the Micro:bit.

    Tap them in the right order.

  3. True or false: if it works in the simulator on the screen, it always works on the real Micro:bit.

  4. When does "on button A pressed" run?

  5. True or false: a program can have an event for button A and another for button B.

  6. How does the heart seem to beat?

  7. True or false: the Micro:bit feels a shake without any extra part.

  8. An AI could write "show string HELLO" for you. What can only you decide?

Predict, then try

Choose what will happen, then try it in the lab or on your board

  1. You type a long name with 12 letters. What will happen?

  2. You press A while your name is still scrolling. Predict, then try.

  3. Story 3 has no on shake block. You shake the badge. What happens?

I can …

Tick what is true for you today. Your ticks stay on this computer.

Find the bug

A mistake we often see in class. What does the board do? Why? How do you fix it?

"I downloaded my program. My name scrolls past once, and then the Micro:bit stays dark. Is it broken?"

The MakeCode blocks of this program
The same in Python
basic.show_string("SAM")
Need a hint?

When does on start run? What does the screen show after the last block?

  • What keeps a picture on the screen after the name?

"At the start I see a smile for a moment, then the surprised face. When I press A or B, nothing changes."

The MakeCode blocks of this program
The same in Python
basic.show_string("SAM")
basic.show_icon(IconNames.HAPPY)
basic.show_icon(IconNames.SURPRISED)
Need a hint?

Which blocks run when you press A? Look for an on button A pressed block.

  • Where does the face for button A go?

"I press B. A heart appears and just stays there. It should beat: big, small, big, small."

The MakeCode blocks of this program
The same in Python
def on_button_pressed_b():
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.HEART)
    basic.show_icon(IconNames.HEART)
input.on_button_pressed(Button.B, on_button_pressed_b)

basic.show_icon(IconNames.HAPPY)
Need a hint?

Look at the pictures in the four show icon blocks. Are they different?

  • What makes the heart beat?

Show it without help

Two minutes: show your badge to someone and explain it

  1. Show your name, then press A and B. Say first what will happen.
  2. Point to the block that runs when you press B.
  3. Change one face and download it again.

Then: What did you make yourself today? What would you like your badge to do next?

Ask one question

Each of you asks one question about today

Ask your teacher or the class one question about today. Anything counts: a part, a block, a word on this page, something that went wrong, or where this is used in real life. There are no wrong questions, only questions nobody asked.

Start with: Why does …?   What happens if …?   How does a real … do it?   What does … mean?   Could I use this to …?

Poster to print (PDF)