-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaster.py
47 lines (37 loc) · 1 KB
/
master.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
38
39
40
41
42
43
44
45
46
47
"""
TODO:
Initialize I2C master
Display (this or seperate pico?)
make a function for writing to SDcard
"""
import os
import board
import busio as io
import digitalio
import storage
import adafruit_sdcard
import microcontroller
from time import sleep
# Use any pin that is not taken by SPI
SD_CS = board.GP13
# Connect to the card and mount the filesystem.
spi = io.SPI(board.GP10, board.GP11, board.GP12)
cs = digitalio.DigitalInOut(SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
with open("/sd/testfile.txt", "w") as writefile:
print("First Line", file=writefile)
writefile.close()
with open("/sd/testfile.txt", "a") as appendfile:
print("Second Line", file=appendfile)
appendfile.close
with open("/sd/testfile.txt", "r") as inputfile:
for line in inputfile:
print(line)
inputfile.close
while True:
# with open("/sd/temphistory.txt", "a") as appendfile:
# print(microcontroller.cpu.temperature, file=appendfile)
# appendfile.close
sleep(1)