-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.py
38 lines (34 loc) · 1 KB
/
code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import board
import digitalio
import microcontroller
import time
led = digitalio.DigitalInOut(board.D13)
led.switch_to_output()
#create logging interval counter
logInterval = 60
logCountdown = 0
try:
with open("/temperature.txt", "a") as fp:
while True:
if(logCountdown <= 0):
temp = microcontroller.cpu.temperature
# do the C-to-F conversion here if you would like
fp.write('{0:f}\n'.format(temp))
fp.flush()
# 5 quick blinks
for blinkLoop in range(0,5):
led.value = not led.value
time.sleep(.2)
# reset Interval counter
logCountdown = logInterval
#blink the led
led.value = not led.value
time.sleep(1)
logCountdown -= 1
except OSError as e:
delay = 0.5
if e.args[0] == 28:
delay = 0.25
while True:
led.value = not led.value
time.sleep(delay)