OLED SSD1306 I2C Examples
We use small OLED displays in many of our labs because:
- They are inexpensive (around $4).
- They are easy to connect via SPI. Just four wires: GND, VCC, Clock and Data.
- 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.
The first step is to find out what type of display graphics chip is used in your OLED.
SH1106 Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Counter Example
In this example we will updated the display 50 times with a 1/10th of a second pause between each refresh. A counter will cycle from 1 to 50.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Animated Box
This draws a title and four lines around a drawing area. It then draws boxes that move to the right.
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 |
|
Bounce on the SH1106 Display using I2C
This example is a ball that bounces around the inside of a border rectangle. Is similar to other bounce examples with the exception that you can't draw on the last row of pixels.
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 |
|