← ACARA Digital Technologies Years 7–8

Reading the micro:bit temperature with input.temperature()

A micro:bit block that returns the temperature reading in degrees Celsius as a number. You can show it with basic.showNumber() or store it in a variable.

Understanding Reading the micro:bit temperature with input.temperature() in ACARA Digital Technologies Years 7–8

What it does: input.lightLevel() is another built-in sensor that returns a number, and basic.showNumber() can display it just like the temperature. The micro:bit reports temperature in degrees Celsius (°C). Without quotes, the code runs and saves the number. With quotes it is just text and no reading is taken. It returns a numeric reading, so you can show it, store it or compare it, for example temp > 25. The variable temp holds the reading, so pass it to basic.showNumber(). The second option is missing the brackets. The brackets () are needed so the block runs and returns the reading. Code is case and spelling sensitive, so a misspelt name is not recognised as the temperature block.

Common mistakes: The variable is called temp, but the broken line uses tmp, which was never created. It should be basic.showNumber(temp). temp is a variable holding a number, not a function, so it has no brackets after it. It should be basic.showNumber(temp).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 204–236) and word search (Modules 189–236).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which code reads the micro:bit's temperature?
input.temperature()input.temp()
Matches
basic.showNumber(input.temperature)
↓
The brackets after input.temperature are missing, so the function is never called and no reading is returned. It should be input.temperature().
Applying
Meanings
Term
input.temperature()
Meaning
A micro:bit block that returns the temperature reading in degrees Celsius as a number. You can show it with basic.showNumber() or store it in a variable.
Practice
let temp = input.temperature()
Testing
Gaps
basic.showNumber(input.())
Check Answer
Spots
3 temp = input.temperature()
4 basic.showNumber(tmp)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Space Turtle' badge — Speed in Zero-G, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which code reads the micro:bit's temperature?
A. input.temperature() ✓
B. input.temp()
The block is called input.temperature(). It returns the temperature as a number.
2. What unit does input.temperature() give you?
A. Degrees Celsius ✓
B. Degrees Fahrenheit
The micro:bit reports temperature in degrees Celsius (°C).
3. Which line shows the temperature on the LED screen?
A. basic.showString(input.temperature)
B. basic.showNumber(input.temperature()) ✓
basic.showNumber() displays a number, and input.temperature() needs its brackets so it runs and returns the reading.
4. Which line stores the temperature reading in a variable?
A. let temp = input.temperature() ✓
B. let temp = "input.temperature()"
Without quotes, the code runs and saves the number. With quotes it is just text and no reading is taken.
5. True or false: input.temperature() returns a number.
A. False, it returns a word like "warm"
B. True, it returns a number like 22 ✓
It returns a numeric reading, so you can show it, store it or compare it, for example temp > 25.

Match the Pairs

basic.showNumber(input.temperature()) → Reads the temperature in degrees Celsius and scrolls the number across the micro:bit LED screen
let temp = input.temperature() → Stores the current temperature reading in a variable called temp so it can be used again later
Show the micro:bit's light sensor reading on the LED screen instead of the temperature → basic.showNumber(input.lightLevel())
Store the temperature in a variable, then display the stored value → let temp = input.temperature() basic.showNumber(temp)
basic.showNumber(input.temperature) → The brackets after input.temperature are missing, so the function is never called and no reading is returned. It should be input.temperature().
let temp = input.temprature() → The function name is misspelled as temprature. It must be spelled input.temperature() exactly or the code will not work.

Key Term

input.temperature()
A micro:bit block that returns the temperature reading in degrees Celsius as a number. You can show it with basic.showNumber() or store it in a variable.

Fill in the Blanks

1. basic.showNumber(input.temperature())
Hint: Type the name of the input function that reads the temperature sensor.
2. let temp = input.temperature()
Hint: Type the keyword that creates a new variable to store the reading.
3. let temp = input.temperature() basic.showNumber(temp)
Hint: Type the variable name that holds the stored temperature reading.
4. let light = input.lightLevel()
Hint: Type the name of the other built-in sensor function that measures brightness.
5. basic.showNumber(input.temperature())
Hint: Type the basic function that displays a number on the LED screen.

Spot the Error

Question 1
A let temp = 0
B basic.forever(function () {
C temp = input.temperature()
D basic.showNumber(tmp)
E })
Line D — The variable is called temp, but the broken line uses tmp, which was never created. It should be basic.showNumber(temp).
Question 2
A let temp = input.temperature()
B basic.pause(500)
C basic.showNumber(temp())
Line C — temp is a variable holding a number, not a function, so it has no brackets after it. It should be basic.showNumber(temp).
Question 3
A let t = input.temperature()
B if (t > 30) {
C basic.showString(Hot)
D }
Line C — Text shown on the micro:bit must be in quotation marks. Without them, Hot looks like a variable name. It should be basic.showString("Hot").
Question 4
A let light = 0
B light = input.lightlevel()
C basic.showNumber(light)
Line B — Names are case-sensitive. The sensor function is input.lightLevel() with a capital L, not input.lightlevel().
Question 5
A let temp = input.temperature
B basic.showNumber(temp)
C basic.pause(1000)
Line A — input.temperature is a function, so it needs brackets to run and return the reading. It should be input.temperature().

Student with a class code? Join your class →