Skip to content

Instantly share code, notes, and snippets.

@overas
Created August 29, 2023 13:58
Show Gist options
  • Save overas/1950710c63069c5d70289d57fffcc26d to your computer and use it in GitHub Desktop.
Save overas/1950710c63069c5d70289d57fffcc26d to your computer and use it in GitHub Desktop.
Microbit måler temperatur og skriver data til en fil
from microbit import *
import time
display.show(Image.HAPPY)
while True:
if button_a.is_pressed():
temperatureValues = open("temperatur.txt", "w")
temperatureValues.write("Minutter" + "," + "Temperatur" + "\n")
break
while True:
tid = str((running_time() // 1000) // 60)
temperatureMeasure = temperature() - 7
temperatureValues.write(str(tid) + "," + str(temperatureMeasure) + "\n")
display.scroll(temperatureMeasure)
if button_b.get_presses() > 0:
temperatureValues.close()
break
time.sleep(60)
display.show(Image.HEART)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment