Friday, 12 June 2015

Interfacing the 0.96" I2C OLED Display

I2C OLED Display

The 0.96" I2C OLED Display is a simple display with plenty of options for displaying text and graphics in monochrome. The display hooks up to the I2C bus and can be accessed using the Address 0x3C. The display is a 128 x 64 Display where it has 128 pixels for every row with a total of 64 rows.

Hooking it up

All it needs to work is 4 lines of connection (SDA, SCL, Vcc, Gnd). You don't need any pullups. Should you have the latest version of the Induino, The Induino R4, you don't even have to use physical wires! the board comes with a Direct Plug in Header for the 0.96" I2C OLED display. Just plug it in and you are good to go!

For Induino R3 or Arduino

For Induino R3 or Arduino

For Induino R3 or Arduino

Plug in Directly on the Induino R4
One you are done with the connections, download this excellent library from DigiSpark. If You are wondering how to install this library? check this ->

The Digispark OLED library offers a number of functions that we can use. The library creates a default object called oled and functions can be called through this object.

The Functions
  • oled.begin() - > This function intialises communication with the oled and does the basic oled setup required.
  • oled.fill(fill color) -> This function fills the display with the chosen fill color. In our case since we are working with a monochrome oled. its only possible to fill it with black or blue(white). use oled.fill(0xFF) to fill the screen with white color and oled.fill(0x00) to fill the screen with black color.
  • oled.clear() -> This function clears the display.
  • oled.setCursor(x,y) -> This function sets the cursor in the given x,y position. X is the coloumn value in pixels and Y is the row value. X can have any value starting 0 - 127. Y can have any value from 0-7. Take font sizes into consideration when deiciding on X & Y values
  • oled.setFont(font size) -> This function sets the font size to be used. There are 2 font sizes available. oled.setFont(FONT6X8) sets the font to be used as a smaller font with each font taking up 6 x 8 pixels. So you can have a total of 168 characters.  oled.setFont(FONT8X16) sets the font to be used as a larger font with each font taking up 8 x 16 pixels. So you can have a total of 64 characters. 
  • oled.print(text/value) -> This function prints the text / value given. oled.print("hello world")
  • oled.println(text/value) -> This functions prints the text / value given and then positions the cursor at the beginning of the next line
  •> Turns the display off
  • oled.on() -> Turns the display on if it has been turned off
  • oled.invert(parameter) -> Inverts the display when the parameter passed is 1 and restores the display when the parameter passed is 0. oled.invert(1) or oled.invert(0)

The Code

Here's a simple code to display hello world and explore the various functions

/*  Induino R3 User Guide - Program 22.0 - 0.96"I2C OLED Usage Example using the Induino R3 */

/* This program explore various functions of the DigisparkOLED library using the Induino R4*/

#include <DigisparkOLED.h> // Header for the OLED library
#include <Wire.h>

void setup()
  // Initialise Communication with the OLED

  // First lets print the line numbers
  // Lets Set the Font to small size. This font takes up one row per character (for the height!)
  oled.setCursor(0, 0);
  //Print the first number using a println so that the cursor is automatically positioned at the start of the next line. Then repeat this till the last number

  // Set the Font to large size. This font takes up two rows per character (for the height!) as agains the small font that takes up one row per character

  // Position the Cursor to print Hello in the middle of the Screen. Given the font size and that we have 8 rows in total, printing on the 4th row will take up the 4th and 5th rows
  // leaving the first and last 3 rows empty
  // given that the 5 characters hello take up 40 pixels, we can print from the 45th pixel to keep it at the center
  oled.setCursor(45, 3);
  // Lets turn off the display;

  // Lets turn on the display

  // Lets invert display

  // Lets restore the inverted display

  // lets wait for some time

  // finally clear the screen


void loop()


Thats It For This Part! Enjoy... and feel free to drop us an email with questions you might have ->

Visit for more interesting products

Back to List of Contents


  1. Just bought the set, fired the test code, worked fine. Combined the above code with the code for DS1307, just doing oled.print() for every Serial.print(), everything worked fine, and the datetime was printed on the OLED screen.

    Removed the oled.clear() to see if the lines would scroll by themselves. Nope, not only did the lines not scroll, it did some weird things on the display, and then went blank. Nothing. Now it doesn't even run the basic program above. What to do?

    1. Don't know what went wrong, but I ran the example program (File>Examples>DigisparkOLED>DigisparkOLED) and it started running again. Then I ran the basic program above, worked fine. Then I ran the modified program (with oled.clear()) and it ran fine.

  2. I like to interface two ping sensors in a obstacle avoider robot using induino R3, whether it is possible to interface two?? if possible pls say about programming??

  3. Hi ,
    Due to some reason , my oled was not working . I installed the new IDE and installed package Adafruit SSD1306 . Also i tried i2cScanner which is not showing any i2c devices . Please help