logger demo
This commit is contained in:
parent
3bf841a306
commit
bcf6ba5813
2 changed files with 35 additions and 0 deletions
24
Introducing_Gemma_M0/Gemma_Logger.py
Normal file
24
Introducing_Gemma_M0/Gemma_Logger.py
Normal 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)
|
||||||
11
Introducing_Gemma_M0/Gemma_Logger_boot.py
Normal file
11
Introducing_Gemma_M0/Gemma_Logger_boot.py
Normal 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)
|
||||||
Loading…
Reference in a new issue