Adding a 128×64 pixels white OLED display to your Arduino project
Nowadays, OLED screens for electronics projects are very affordable. They come in many shapes and sizes. Some are monochrome or two color but you can also get full color screens. They are definately worth a look when your Arduino projects needs to display some shar, crisp output. This post is about a nice little 128×64 pixels white OLED display based on the SSD1306 OLED driver IC.
Getting it to work
I was trying to get a tiny 0.96 inch monochrome (white) screen from VNG Systems to work on my Arduino Uno and Nano. It has a resolution of 128×64 pixels and has a nice sharp and bright image. It is a 6 pin SPI version. As the instructions suggested, I hooked it up to my Nano and installed the U8glib library. Unfortunately I could not get it to work, and after a while of tinkering around I decided to find a different approach. After some Googling I tried rewiring the connections and finaly got it working with the Adafruit SSD1306 library,
Connecting the 0.96 Inch 128×64 pixels white OLED display module
This screen is the 6 pin SPI version, so hooking it up to your Arduino is easy. I found some different approaches on the internet but this is what worked for me. Connect the screen to your Arduino like this:
Installing and modifying the Adafruit SSD1306 library
Start the Arduino IDE and install the Adafruit SSD1306 library:
- Go to Sketch > Include library > Manage libraries
- Search for ‘SSD1306’, then select and install the Adafruit library
Then open the file ‘Adafruit_SSD1306.h‘ (located in your libraries folder, for me it was in ~/Arduino/libraries/Adafruit_SSD1306/).
Find the lines:
// #define SSD1306_128_64 #define SSD1306_128_32 // #define SSD1306_96_16
and change it to:
#define SSD1306_128_64 // #define SSD1306_128_32 // #define SSD1306_96_16
Note: If you’re using Windows and have trouble opening or editing the file, use a text editor like Notepad++ instead of Window’s default Notepad.
Don’t forget to save the file!
Running the example sketch
Now it’s time to test your display. You can do so by using the example sketch ‘ssd1306_128x64_spi‘ which comes with the SSD1306 library.
- Go to File > Examples > Adafruit SSD1306
- Load the ‘sd1306_128x64_spi’ sketch
Compile and upload it to your Arduino and you shoud see the demo animations. Study the exampe to see how you can incorporate the OLED screen into your own projects!