Track highest and lowest temperatures by leaving this program running on a micro:bit.
What you need
- micro:bit (or MakeCode simulator)
- MakeCode or Python editor
- battery pack (optional)
- a source of heat or cooling, like a fan, if you want to see the temperature change quickly – or take the micro:bit outside
- Code It
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from microbit import *
currentTemp = temperature()
max = currentTemp
min = currentTemp
while True:
display.show('.')
currentTemp = temperature()
if currentTemp < min:
min = currentTemp
if currentTemp > max:
max = currentTemp
if button_a.was_pressed():
display.scroll(min)
if button_b.was_pressed():
display.scroll(max)
sleep(1000)
display.clear()
sleep(1000)
Comments