Introduction to OLED Displays
Four colors of 2.44" OLED displays from DIY More. We can purchase them on EBay for around $18 each.
We use small OLED displays in many of our labs because:
- They are inexpensive (around $4).
- They are easy to connect** via I2C and SPI. Just four wires for I2C and seven wires for SPI.
- They have a large area to display feedback. Most of them are 128X64 pixels.
- Once you get the drivers installed (not always easy) they are easy to program. You only need to initialize the device and run the oled.fill(), oled.text() and oled.show() functions.
- OLEDs, unlike LCDs, have high contrast over a large range of input voltages. This means that as your batteries slowly discharge, your OLEDs will keep their high-quality contrast.
- There is plenty of sample code and tutorials available.
- You can program them with Python (our student's favorite language)
- They are crazy fun!
The first step is to find out what type of display graphics chip is used in your OLED.
In these lessons we will assume you have a 128X64 or similar OLED display. Many of these displays can be purchased for around $4 on eBay. Many of these displays use the popular SSD1306 chip to drive the displays. There are also to communication options:
- I2C - simple 2 wire connection (not including power and ground)
- SPI - five wires but also faster screen refresh rates
Updating a 128X64 display using I2C takes around 37ms. When using the SPI interface, updating the display can be reduced to around 2.79ms.
These labs will assume these parameters, but you can modify the labs to use different sizes and display driver chips by only modifying a few lines of code.
Because your microcontroller might have multiple displays on it, their must be some way to address the devices using an address. Most of the devices come with a default address of decimal value 60 (hex value X3C). To test this the i3c module has a i2c scan function.
1 2 3 4 5
If you don't see a return value of "60" or similar, then you need to check your wiring and make sure that you have an I2C (not an SPI) device.