Game Microbit
Advanced
60 mins
Teacher/Student led
+105 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.

Learning Goals Learning Outcomes Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
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[] = []
    
    

    5 - Correct guess

    When the item is being displayed on the Microbit the player will ask questions to the other people such as "Is it an animal?" or "Is it a place?".

    If he or she guesses it right then they will tilt the Microbit so the screen is pointing down. This will give them a point.

    Add the following code to your project.

    input.onGesture(Gesture.ScreenDown, function () {
        game.addScore(1)
    })
    
    

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. 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