0.96″ OLED i2c
This article shows how to use the SSD1306 0.96 inch I2C OLED display with the Arduino. We’ll show you some features of the OLED display, how to connect it to the Arduino board, and how to write text and draw shapes. The organic light-emitting diode (OLED) display that we’ll use in this tutorial is the SSD1306 model: a duocolor, 0.96-inch display with 128×64 pixels. The model we’re using here has only four pins and communicates with the Arduino using I2C communication protocol. The display works without any problem with arduino, NodeMCU and Digispark Attiny85, and the price of the display is very low.
Connection:
Connects using the i2c protocol, so it needs 2 communication cables and 2 power cables.
Display to Arduino Uno
- Vcc to 5V
- GND to GND
- SCK to A5
- SCL to A4
Other Board:
- Nano: SDA (A4); SCL (A5);
- MEGA: SDA (20); SCL (21);
- Leonardo: SDA (20); SCL (21);
Libraries:
To using the OLED display you need the adafruit_SSD1306.h and the adafruit_GFX.h libraries. Open Arduino IDE -> Tools -> Libraries Menager and install libraries
Display on the screen


Test
Now, open the sample program to test the display. Arduino IDE -> File -> Examples -> Adafruit SSD1306 -> ssd 1306_128x64_i2c. Upload Sketch.

1 2 3 4 5 6 7 |
display.clearDisplay() – // Clear Display display.setTextSize(size) –// set the font size, supports sizes from 1 to 8 display.setCursor(x,y) –// set the coordinates to start writing text display.print(“text”) – // print the text at location x,y display.setCursor(x,y) –// set the coordinates to start writing text display.print(value) – // print the value at location x,y display.display() – // call this method for the changes to make effect |