You're previewing the student experience. You don't need to complete this lesson — your progress and XP aren't saved.
Microbit
Beginner
60 mins
Teacher/Student led
+185 XP
What you need:
Chromebook/Laptop/PC

Exploring Microbits

Get started with programming a microbit in this hands-on lesson. You'll learn to create a project, display messages, and make your microbit react to button presses. Follow the steps to code and explore its exciting features!

Teacher Class Feed

Load previous activity

    1 - What is a microbit?

    Meet the microbit! A microbit is a small, pocket-sized computer that we can program to do fun and interesting things.

    It's like a tiny, interactive billboard that can display messages, play sounds, and react to your actions. You can program it to respond to buttons being pressed and even movement.

    In this lesson, we're going to learn how to program the microbit to show messages and react to button presses. Let's get started!



    2 - Create a new project

    Did you know we can program our microbit using a website? To start our coding adventure, we need to create a new project.

    First, open the website MakeCode for microbit.

    Once you're there, look for a button that says 'New Project' and click on it. It will ask you what you want to call your project. Give your project a name (for example 'my project') and then click on the 'Create' button.

    This will open a new, blank project where we can start programming our microbit and give it instructions.


    3 - The Project Editor

    Let's take a look around the projector editor screen.

    Microbit Simulator
    On the left side of the screen, you'll see a simulator of a microbit. When we create some code, we will see it play in the simulator.

    Toolbox
    On the right side of the simulator, you'll see a toolbox with different categories of blocks. Each of these blocks is a different type of instruction for the microbit.

    Code Area
    On the right is the code area where we will write our code. It starts with two code blocks already added:
    on start and forever. on start is used for code that should run once when the microbit starts up. forever is used for code that should keep running over and over again.


    4 - Add Our First Code!

    Now let's add our first piece of code. The microbit has a grid of little red LED lights and we're going to make the microbit show some numbers using those lights.

    Add the following code:

    basic.showNumber(0)
    Once you've added that code, the microbit simulator should show the number 0.

    Next change the number 0 to a different number, in our example we changing it to the number 4:

    basic.showNumber(4)
    Now the simulator should refresh and show the number 4.




    5 - Delete Some Code

    Now let's delete the show number code block. We can do this by dragging and dropping it back into the toolbox.

    6 - Display Your Name

    Now let's program one of the buttons on the microbit. The microbit has a grid of little red LED lights and when you press the A button, we're going to make the microbit display our name using those lights.

    Add the following code (but put in your own name):

    input.onButtonPressed(Button.A, function () { basic.showString("Susan") })
    Once you've added that code, click on the circle of the A button in the simulator and it should display your name, one letter at a time.


    7 - Show a Happy Face

    Next, we are going to instruct our microbit to display a happy face when we press the B button. This is a fun way to express our emotions using our microbit.

    Add the following code:

    input.onButtonPressed(Button.B, function () { basic.showIcon(IconNames.Heart) })
    Once you've added this code, press the B button on the simulator. You should see a happy face light up on the microbit.

    Then choose a different icon by clicking on the little white down arrow in the show icon block. This will open the icon library and you can select a different icon.

    input.onButtonPressed(Button.B, function () { basic.showIcon(IconNames.Happy) })
    The simulator will refresh and should show the new icon.




    8 - Connect your Microbit

    Now let's put our code on are actual microbit devices and see it work in the real world!

    Connect your microbit to your computer (follow the instructions below). Once it's connected click on the download button and your code will be sent to your microbit.

    Press the A button and it should show your name.

    Press the B button and it should show your icon.

    9 - Play Some Music

    Now, let's make our microbit play some music! We're going to program the microbit to play a melody when we press both the A and B buttons together.

    Add the following code and select a melody from the gallery or program your own!

    input.onButtonPressed(Button.AB, function () {
        music.play(music.stringPlayable("E B C5 A B G A F ", 120), music.PlaybackMode.UntilDone)
    })
    
    Once you've added that code, press the A and B buttons together on the simulator. You should hear a melody playing. Try changing the melody to a different one from the melody library and see how it sounds!

    When you're done, download your updated code to your microbit and try it on your actual microbit.

    10 - Explore!

    Now that you've learned the basics of programming your microbit, it's time to explore! Try out different blocks from the toolbox and see what they do. You can make your microbit display different messages, react to button presses, and even respond to movement.

    Don't forget to download your updated code to your actual microbit each time you make changes. Have fun exploring!
    End of lesson
    123learn · Sample lesson

    That was a sample lesson from Microbit Innovators

    Every lesson in the course is ready to teach like this one. See what else comes with it, and how to order it.

    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2026. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more