Created
June 30, 2017 18:07
-
-
Save tannewt/378ef9c69a9858d1a18c546b2548529d to your computer and use it in GitHub Desktop.
sdcard test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import adafruit_sdcard | |
import busio | |
import digitalio | |
import board | |
import storage | |
import os | |
import gc | |
spi = busio.SPI(board.SCK, board.MOSI, board.MISO) | |
cs = digitalio.DigitalInOut(board.D10) | |
sdcard = adafruit_sdcard.SDCard(spi, cs) | |
vfs = storage.VfsFat(sdcard) | |
for entry in vfs.ilistdir(): | |
print(entry) | |
storage.mount(vfs, "/sd") | |
del spi | |
del sdcard | |
del vfs | |
gc.collect() | |
with open("/sd/test.txt", "w") as f: | |
f.write("Hello world\n") | |
print(os.listdir("/sd")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment