This post may contain affiliate links. See the affiliate disclosure for more information.

In this tutorial I will show you how to use an OLED Display with Arduino. There are several types of displays available in the market, namely: LCD (Liquid Crystal Display), LED, OLED (Organic LED) and eInk display. LCD and OLED are the most common ones. In this post we will learn how to use OLED display with Arduino. Let’s begin.

Materials for this Project

To create this project, you’ll need the following materials:

  1. Arduino: We’ll use this controller as the brain of the project. I used the Arduino UNO but feel free to use whichever Arduino board you like (Mega, Nano or Micro). Just make sure you know the Pin mapping of your board.
  2. OLED Display: There are different types of OLED displays. The one I have used is 1.3″ I2C module. It has a resolution of 128 x 64 and works with the SH1106 Driver.
  3. Proper driver for the display: I used the SH1106 driver, so I installed the Adafruit_SH1106 library for that. Make sure you check what driver your display needs. It should be mentioned in the description of product on the website.

Understanding I2C Protocol:

As our display module uses I2C interface for communication, We must first understand the I2C Protocol.

I2C is a communication method which only uses 4 pins. In this Protocol, multiple Masters (Microcontrollers) can be connected to multiple slaves (Sensors) using 4 pins: VCC, GND, SDA and SCL.

I2C Protocol Diagram

In I2C data is transferred in form of packets. These packets contain frames of data.
I2C Message DiagramFirst frame contains a “Start Condition”, when a device reads the start frame it gets ready for incoming data. Next frame contains the address of the device. Then there are two data frames which contain the instructions. Finally the Stop condition indicates the end of the packet.

The Ack/Nack Bits are the acknowledge bits , when set of data is received successfully acknowledge bit is sent. This was a short explanation of I2C, for in depth information refer I2C Wiki.

OLED Arduino Wiring Diagram

OLED Arduino Fritzing diagram

Connections are very simple, just follow the diagram and you’re done. OLED displays are very power efficient and works perfect on 3v. After the connections are made, it’s time to upload the test code.

Program OLED Display with Arduino

Before we can upload the code, there are a couple of libraries that needs to be installed. Below I have listed the libraries needed:

The Wire.h library must be already installed in IDE, Download the SH1106 library from here.
Click “Clone or Download” on the right. Then choose “Download ZIP.” Extract the Zip file and copy it into Arduino >> Libraries.

Then , create a new sketch, and write the code given below:

#include <Wire.h>
#include <Adafruit_SH1106.h>

#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);

void setup()
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);


void loop()

Upload the code to the Arduino, and you should see a “Hello World!” message on the screen. You can also try the example code present in Arduino IDE.

Goto File >> Examples >> Adafruit_SH1106-Master >> sh1106_128x64_i2c

Upload the example code to see some cool animations.


Final Note

With that complete, now you can use the OLED display for your projects. These displays can be very useful for projects such as a weather station, robot display, or electronic dice. The possibilities are endless once you learn the basic configuration.

Arduino OLED Hello World

If you enjoyed this tutorial, consider buying a copy of my Mini WIFI robot eBook. I show you how to design, build, and program your very own custom robot that can be controlled over WIFI. Pick up your copy, today!

Pin It on Pinterest

Is this content Share-Worthy?

Tell a Friend about it!