ePaper display driven by a Raspberry Pi Pico
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
937 B

  1. import machine
  2. import sdcard
  3. import uos
  4. # Assign chip select (CS) pin (and start it high)
  5. cs = machine.Pin(17, machine.Pin.OUT)
  6. # Intialize SPI peripheral (start with 1 MHz)
  7. spi = machine.SPI(0,
  8. baudrate=1000000,
  9. polarity=0,
  10. phase=0,
  11. bits=8,
  12. firstbit=machine.SPI.MSB,
  13. sck=machine.Pin(18),
  14. mosi=machine.Pin(19),
  15. miso=machine.Pin(16))
  16. # Initialize SD card
  17. sd = sdcard.SDCard(spi, cs)
  18. sd_path = "/sd"
  19. # Mount filesystem
  20. vfs = uos.VfsFat(sd)
  21. uos.mount(vfs, sd_path)
  22. # Create a file and write something to it
  23. with open(sd_path + "/test01.txt", "w") as file:
  24. file.write("Hello, SD World!\r\n")
  25. file.write("This is a test\r\n")
  26. # Open the file we just created and read from it
  27. with open(sd_path + "/test01.txt", "r") as file:
  28. data = file.read()
  29. print(data)
  30. uos.mount(sd_path)