This week in micro:bit Monday we will be looking at the temperature sensor to detect what the temperature is and display it on the LED matrix.
You can do this indoors tethered to your computer by the USB cable or why not attach a battery pack and take it outdoors and see what the difference in temperature is!
- Open MakeCode within your favourite browser and open a new project
- Click and drag the on start block to the left of the screen and drop it in the bin
- Click on Basic, click and drag a show number 0 block to the code area and attach it within the forever block
- Click on Input, click and drag a temperature (°c) block to the code area and drop it within the 0 of the show number block
Now you can download your code and test on an actual micro:bit!
- Open EduBlocks within your favourite browser and click on micro:bit
- Click on Basic, click and drag a from microbit import
*block to the code area and drop it
- Click on Basic, click and drag a while True: block to the code area and attach it under from microbit import
- Click on Display, click and drag a display.scroll(0) block to the code area and attach it within the while True: block
- Click within the 0 of the display.scroll block and type temperature ()
Your code is now completed and ready to download to your micro:bit
- Open your favourite Python editor used to code the micro:bit
from micro:bit import *This will import the micro:bit library and allow you to interact with the micro:bit
while True:This will create a loop that will keep executing the instructions inside it forever
display.scroll(temperature())This will scroll the current temperature across the LED matrix
Your code is now complete and ready to download(flash) to your micro:bit
from microbit import * while True: display.scroll(temperature())
That’s it for this week come back next Monday to find out how to use the compass on the micro:bit