prjbrook

Pi Pico Oled 1

Jun 20th, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1.  
  2. # Basic example of clearing and drawing pixels on a SSD1306 OLED display.
  3. # This example and library is meant to work with Adafruit CircuitPython API. & WorkedTue Jun 21 14:14:22 NZST 2022
  4.  
  5. # Import all board pins.
  6. #from board import SCL, SDA
  7. import busio
  8.  
  9. # Import the SSD1306 module.
  10. import adafruit_ssd1306
  11. import board
  12.  
  13. # Create the I2C interface.
  14. #i2c = busio.I2C(board.SCL, board.SDA)
  15. i2c = busio.I2C(board.GP17, board.GP16)
  16. #i2c = busio.I2C(GP17,GP16)
  17. # Create the SSD1306 OLED class.
  18. # The first two parameters are the pixel width and pixel height. Change these
  19. # to the right size for your display!
  20. display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
  21. # Alternatively you can change the I2C address of the device with an addr parameter:
  22. # display = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, addr=0x31)
  23.  
  24. # Clear the display. Always call show after changing pixels to make the display
  25. # update visible!
  26. display.fill(0)
  27. display.show()
  28.  
  29. # Set a pixel in the origin 0,0 position.
  30. display.pixel(66, 0, 1)
  31. # Set a pixel in the middle 64, 16 position.
  32. display.pixel(64, 16, 1)
  33. # Set a pixel in the opposite 127, 31 position.
  34. display.pixel(127, 31, 1)
  35. display.show()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment