logger demo

This commit is contained in:
ladyada 2017-09-29 00:06:25 -04:00
parent 3bf841a306
commit bcf6ba5813
2 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import board
import digitalio
import microcontroller
import time
led = digitalio.DigitalInOut(board.D13)
led.switch_to_output()
try:
with open("/temperature.txt", "a") as fp:
while True:
temp = microcontroller.cpu.temperature
# do the C-to-F conversion here if you would like
fp.write('{0:f}\n'.format(temp))
fp.flush()
led.value = not led.value
time.sleep(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)

View file

@ -0,0 +1,11 @@
import digitalio
import board
import storage
switch = digitalio.DigitalInOut(board.D0)
switch.direction = digitalio.Direction.INPUT
switch.pull = digitalio.Pull.UP
# If the D0 is connected to ground with a wire
# CircuitPython can write to the drive
storage.remount("/", switch.value)