Game Microbit
Advanced
60 mins
Teacher/Student led
+135 XP
What you need:
Chromebook/Laptop/PC
Microbit

Head Guess Game

In this guessing game the player holds the Microbit on their head and has 1 minute to guess random things that appear on the Microbit.

Teacher Class Feed

Load previous activity

    1 - Create a new Microbit project and understand the game

    In this lesson, you will be creating a fun and engaging guessing game using your Microbit. The game is called 'Head Guess Game'. The player holds the Microbit on their head and has 1 minute to guess random things that appear on the Microbit's LED display. The game will involve creating a countdown timer, a list of random things to guess, and coding the Microbit to display these things. You will also code the game's logic for correct guesses, passes, and game over scenarios.

    Let's start by setting up your new project. Go to the MakeCode Microbit website and create a new project. Give your project a name, such as 'Head Guess Game'.

    2 - Start the countdown

    In the game the player will have 60 seconds to guess as many things as possible.

    Add the following code to start the countdown and give the player 2 lives.

    game.setLife(2)
    game.startCountdown(60000)
    
    
    There are 1,000 milliseconds in 1 second, so 60,000 milliseconds equals 60 seconds.

    3 - Create a list of random things

    We need a list of the random words that will appear on the Microbit screen (by scrolling across).

    Create a text list by adding the following code underneath the start countdown block. Add in lots of different random things, animals, people etc.

    game.setLife(2)
    game.startCountdown(60000)
    let text_list = ["Galway", "plane", "xbox", "Ronaldo"]
    
    

    4 - Show one of the things

    To get a new thing from the list, the player will put the Microbit with the logo up. When the Microbit detects this gesture, we will pick a random item from our list and display it.

    So if we have 5 items in our list they will be indexed as follows:
    0.) apple
    1.) moon
    2.) plane
    3.) xbox
    4.) Kerry

    The amount of items (or length of our list) is 5, so if we are choosing a random item using the index we will need to choose between 0 and 4 (or between 0 and [5 minus 1]).

    Add the following code.

    input.onGesture(Gesture.LogoUp, function () {
        basic.showString("" + (text_list[randint(0, text_list.length - 1)]))
    })
    let text_list: string[] = []
    
    

    123learn · Online learning platform

    Unlock the full learning experience

    You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    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