Welcome to Pico Robot Car repository
3.6 OLED display
3.6 OLED display
1. Learning objectives
- Learn to combine the Raspberry Pi Pico 2/Pico mainboard and the OLED display of the car expansion board for experiments.
- Understand the use of OLED display.
2. Hardware use
This course uses the Pico 2/Pico mainboard and the OLED display of the car expansion board. Note that before running this section of the routine, the OLED display must be plugged in, otherwise the program will report an error.

OLED display is a display made of organic light-emitting diodes. Because it has both self-luminous organic light-emitting diodes, it does not require a backlight, has high contrast, thin thickness, wide viewing angle, fast response speed, wide operating temperature range, and simpler structure and process. The 0.91-inch OLED screen we use uses IIC communication, which saves IO pins and simplifies the control method.
3. Program analysis
Code path: Code -> 1.Basic course -> 6. OLED display.py
xfrom machine import Pin, I2Cfrom pico_car import SSD1306_I2Cimport time# set IIC pini2c=I2C(1, scl=Pin(15),sda=Pin(14), freq=100000)# initialization oledoled = SSD1306_I2C(128, 32, i2c)# oled show hello at 0,0oled.text('Hello', 0, 0)oled.show()oled.fill(0)time.sleep(1)# oled show World at 0,10oled.text('World', 0, 10)oled.show()oled.fill(0)time.sleep(1)# oled show spot at 100,30oled.pixel(100, 30, 1)oled.show()oled.fill(0)time.sleep(1)
from pico_car import SSD1306_I2C
Use pico_car's SSD1306_I2C, which is our packaged OLED library.
import time
The "time" library. This library handles everything to do with time, from measuring it to inserting delays into your program. The unit is seconds.
from machine import Pin, I2C
The machine library contains all the instructions MicroPython needs to communicate with Pico and other MicroPython-compatible devices, extending the language of physical computing. Only the Pin and I2C libraries are used here.
i2c=I2C(1, scl=Pin(15),sda=Pin(14), freq=100000)
Set IIC 1 pin to SCL 15, SDA 14, and frequency to 100000.
oled = SSD1306_I2C(128, 32, i2c)
Initialize the size of OLED to 128*32, and pass the previously set IIC parameters into it.
oled.text('Hello', 0, 0)
Set OLED to display 'Hello' at position 0,0.
oled.show()
Display the set OLED content.
oled.fill(0)
Clear the set content and prepare for the next display.
oled.pixel(100, 30, 1)
Set the pixel at the coordinate 100,30 of OLED to light up. If oled.pixel(100, 30, 0) is set to turn off the pixel at the coordinate 100,30.
4. Experimental Phenomenon
After the program is downloaded, we can see that OLED first displays 'Hello', then displays 'World' in the next line, and then displays a dot at the coordinate 100,30.