Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

RPi Pico: Using SSD1306 OLED Display With I2C Protocol

Required Components

▶ Required Hardware
◼ Raspberry Pi Pico
◼ 4 jumper wires
◼ SSD1306 OLED Display (with 128x64 or 128x32 pixels)

▶ Required Software
◼ SSD1306 OLED Library (install as a package from Thonny IDE)

Diagram
Code

from machine import Pin, I2C


from lib.ssd1306 import SSD1306_I2C
import utime

# turn internal led on


led = Pin(25, Pin.OUT)
led.high()

# oled display init


WIDTH = 128
HEIGHT = 64

i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000)


oled = SSD1306_I2C(WIDTH, HEIGHT, i2c)

oled.fill(1)
oled.show()
utime.sleep(2)

# welcome message
oled.fill(0)
oled.text("Welcome!", 35, 0)
oled.text("Simplified Ttrls", 0, 8)
oled.text("3.ABCDEFGHIJKLM", 0, 16)
oled.text("4.NOPQRSTUVWXYZ", 0, 24)
oled.text("5.01234567890123", 0, 32)
oled.text("6.ABCDEFGHIJKLM", 0, 40)
oled.text("7.NOPQRSTUVWXYZ", 0, 48)
oled.text("8.01234567890123", 0, 56)
oled.show()
utime.sleep(2)

# looop example
i = 0
while True:
i = i + 1
print (str(i % 20))

oled.fill(0)
oled.text("I'm counting...", 5, 20)
oled.text(str(i % 20), 55, 36)
oled.show()

utime.sleep(1)

```

You might also like