from board import *
from time import *
import busio
import sdcardio
import storage
spi = busio.SPI(GP10, MOSI=GP11, MISO=GP12)
cs = GP15
sd = sdcardio.SDCard(spi, cs)
vfs = storage.VfsFat(sd)
storage.mount(vfs, '/sd')
with open("/sd/test1.txt", "w") as file:
file.write("1. Hello, world!\r\n")
with open("/sd/test1.txt", "a") as file:
file.write("2. This is another line!\r\n")
with open("/sd/test1.txt", "a") as file:
file.write("3. Last but not least!")
with open("/sd/test1.txt", "r") as file:
print("Printing lines in file:")
for line in file:
print(line, end='')
ไม่มีความคิดเห็น:
แสดงความคิดเห็น