How To Make Thermometer Using Micro Bit ?

 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
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)

Leave a Reply

Your email address will not be published. Required fields are marked *