OLED SSD1351 Color Display
Welcome to the SSD1351 Color OLED Lab
In this lab, you will connect a small but stunning color OLED display. Every pixel glows with its own light — no backlight needed!
What Is This Display?
The SSD1351 is a driver chip for small color Organic Light-Emitting Diode (OLED) displays. OLED is different from LCD. In an LCD, a backlight shines through the screen. In an OLED, each pixel makes its own light. This gives you much deeper blacks and brighter colors.
This display is 1.5 inches diagonal. It shows 128 pixels wide by 128 pixels tall. The price is about $40, which makes it more expensive than most LCD displays. But the color quality and viewing angle are excellent.
It uses a Serial Peripheral Interface (SPI) connection to talk to the Pico.
OLED vs LCD
An OLED pixel that shows black is completely turned off — no light at all. An LCD showing black still has the backlight glowing behind it. This is why OLEDs have much deeper, truer blacks.
Drawing Shapes Demo
This program shows how to draw many different shapes on the display. It starts with simple lines and rectangles, then moves on to circles and polygons.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
What Each Line Does
from ssd1351 import Display, color565— loads the SSD1351 driver and the color converter function.spi = SPI(2, baudrate=14500000, sck=Pin(18), mosi=Pin(23))— starts SPI bus 2 at 14.5 million bits per second (close to the maximum for this driver).display = Display(spi, dc=Pin(17), cs=Pin(5), rst=Pin(16))— creates the display with its three control pins.display.clear(color565(64, 0, 255))— fills the whole screen with a blue-purple color.display.clear()— clears the screen to black (no color given means black).draw_hline(x, y, length, color)— draws a horizontal line from point (x, y) goinglengthpixels to the right.draw_vline(x, y, length, color)— draws a vertical line from point (x, y) goinglengthpixels down.fill_hrect(x, y, width, height, color)— fills a rectangle starting at (x, y).draw_line(x1, y1, x2, y2, color)— draws a straight line between two points.draw_lines(coords, color)— draws a series of connected lines through a list of (x, y) points.fill_polygon(sides, x, y, radius, color)— fills a regular polygon with the given number of sides.fill_circle(x, y, radius, color)— fills a circle centered at (x, y).draw_circle(x, y, radius, color)— draws only the outline of a circle.fill_ellipse(x, y, r_x, r_y, color)— fills an ellipse (a stretched circle) with horizontal radiusr_xand vertical radiusr_y.draw_ellipse(x, y, r_x, r_y, color)— draws only the outline of an ellipse.display.cleanup()— sends a shutdown command to the display and closes the SPI connection cleanly.
Monty's Tip
The color565() function takes red, green, and blue values from 0 to 255. Try mixing values to create your own custom colors!
SSD1351 MicroPython Driver
You need to install the driver before running this code. The driver file is ssd1351.py.
You can find the driver here:
Download ssd1351.py and copy it to your Pico using Thonny or mpremote.
Watch Out!
Make sure the SSD1351 driver file is saved on the Pico, not just on your computer. The Pico runs the code from its own storage, so the driver must be there too.
SSD1351 Datasheet
You can read all the technical details about the SSD1351 chip here:
SSD1351 Datasheet (PDF) — NewHaven Displays
Great Work!
You learned how to draw lines, shapes, circles, and polygons on a color OLED display! Next, try writing a program that draws your own pattern or picture using these drawing functions.