This blog post will explain how to use a Raspberry Pico W and MicroPython to write text characters to an OLED screen. The code that is displayed below will accomplish this task. First, the required libraries will have to be declared. I2C will be initalized by declaring a variable and will hold information of what scl and sda pins are being used. The OLED screen will be initialized by declaring a variable. The screen is cleared by using the statement oled.fill(0). Text is printed to the display by using the statements oled.text(‘example’,0,0), and oled.show().
from machine import Pin, I2C
from picobricks import SSD1306_I2C
i2c = I2C(0, scl=Pin(5), sda=Pin(4))
oled = SSD1306_I2C(128, 64, i2c, addr=0x3c)
oled.fill(0)
oled.text(‘Hello world.’, 0, 0)
oled.show()
oled = SSD1306_I2C(128, 64, i2c, addr=0x3c)
oled.fill(0)
oled.text(‘Hello world.’, 0, 0)
oled.show()
The Picobricks zero to hero kit was used to write this blog post.