Microbit Sensors & Circuits
Beginner
60 mins
Teacher/Student led
65 points
What you need:
Chromebook/Laptop/PC
Microbit

Temperature Tales

In this step-by-step lesson, you'll first set up your Microbit on the coding platform. Then, you'll write code to read the temperature from the Microbit's sensor. You'll create a narrative that changes based on temperature readings, code this story into your Microbit, and finally present your temperature-responsive story to the class.
Learning Goals Learning Outcomes Teacher Notes

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 - Step 1: Setting Up Your Microbit

    First, you'll need to setup your Microbit. Go to the Microbit coding platform and start a new project. Click on 'New Project' in the 'Projects' dropdown menu. Give your project a name, for instance, 'Temperature Tales'.

    2 - Step 2: Reading Temperature

    Next, write code to read the temperature from your Microbit's temperature sensor. Drag and drop the 'show number' block from the 'Basic' category into the coding area. Then, from the 'Input' category, drag and drop the 'temperature' block inside the 'show number' block. Your code should look like this:

    basic.showNumber(input.temperature())
    

    Upload your code to the Microbit and test it to ensure that it correctly displays the current temperature.

    3 - Step 3: Creating Your Story

    Now, it's time to create your story. Decide on a narrative that changes based on the temperature. For example, you might tell a story about a snowman that melts as the temperature increases. Write down your story, making sure to include different versions for low, medium, and high temperatures. Keep your sentences short as the display of Microbit is limited.

    4 - Step 3: Coding Your Story

    Next, code your story into your Microbit. Use 'if' blocks from the 'Logic' category to check the current temperature and display different parts of your story depending on the temperature. For example:

    if (input.temperature() < 10) {
    basic.showString("Snowman is cold!")
    } else if (input.temperature() < 20) {
    basic.showString("Snowman is melting!")
    } else {
    basic.showString("Snowman is gone!")
    }
    

    Upload your code and test your story to make sure it changes correctly with the temperature.

    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