Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use oled display: Examples, Pinouts, and Specs

Image of oled displayDesign with oled display in Cirkit Designer

Introduction

An OLED (Organic Light Emitting Diode) display is a type of screen technology that uses organic compounds to emit light when an electric current is applied. Unlike traditional LCDs, OLED displays do not require a backlight, resulting in deeper blacks, higher contrast ratios, and improved energy efficiency. These displays are known for their vibrant colors, wide viewing angles, and thin form factor.

Common applications of OLED displays include:

Explore Projects Built with oled display

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino Leonardo Controlled OLED Display with Pushbutton Interaction: A project utilizing oled display in a practical application
Arduino Leonardo Controlled OLED Display with Pushbutton Interaction

This circuit features an Arduino Leonardo microcontroller connected to a 0.96" OLED display and a pushbutton with a pull-up resistor. The OLED display communicates with the Arduino via I2C (SDA and SCL lines), and the pushbutton, when pressed, changes the display content on the OLED screen. The microcontroller's code suggests the display alternates between showing an overview with speed and experience points and a player stats screen, likely for a game or interactive application.

Open Project in Cirkit Designer

Technical Specifications

Below are the general technical specifications for a typical 0.96-inch I2C OLED display module:

Parameter Specification
Display Type OLED (Organic Light Emitting Diode)
Resolution 128 x 64 pixels
Interface I2C (Inter-Integrated Circuit)
Operating Voltage 3.3V - 5V DC
Current Consumption ~20mA (varies with brightness)
Viewing Angle >160°
Pixel Color Monochrome (White, Blue, or Yellow)
Dimensions ~27mm x 27mm x 4mm

Pin Configuration

The OLED display module typically has 4 pins for I2C communication. The pinout is as follows:

Pin Name Description
1 GND Ground connection
2 VCC Power supply (3.3V or 5V)
3 SCL Serial Clock Line for I2C communication
4 SDA Serial Data Line for I2C communication

Usage Instructions

Connecting the OLED Display to an Arduino UNO

To use the OLED display with an Arduino UNO, follow these steps:

  1. Connect the GND pin of the OLED display to the GND pin on the Arduino.
  2. Connect the VCC pin of the OLED display to the 5V pin on the Arduino.
  3. Connect the SCL pin of the OLED display to the A5 pin on the Arduino (I2C clock line).
  4. Connect the SDA pin of the OLED display to the A4 pin on the Arduino (I2C data line).

Installing Required Libraries

To control the OLED display, you need to install the following libraries in the Arduino IDE:

  1. Open the Arduino IDE.
  2. Go to Sketch > Include Library > Manage Libraries.
  3. Search for "Adafruit GFX" and "Adafruit SSD1306" in the Library Manager.
  4. Install both libraries.

Example Code

The following example code demonstrates how to display text on the OLED screen:

#include <Adafruit_GFX.h>       // Graphics library for OLED
#include <Adafruit_SSD1306.h>   // Library for SSD1306 OLED

#define SCREEN_WIDTH 128        // OLED display width, in pixels
#define SCREEN_HEIGHT 64        // OLED display height, in pixels

// Declaration for an SSD1306 display connected via I2C
#define OLED_RESET -1           // Reset pin (not used with I2C)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  // Initialize the display
  if (!display.begin(SSD1306_I2C_ADDRESS, 0x3C)) { 
    // Address 0x3C for most 128x64 OLEDs
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  display.clearDisplay();        // Clear the buffer
  display.setTextSize(1);        // Set text size (1 = small, 2 = medium, etc.)
  display.setTextColor(SSD1306_WHITE); // Set text color to white
  display.setCursor(0, 0);       // Set cursor position (x, y)
  display.println(F("Hello, OLED!")); // Print text to the buffer
  display.display();             // Display the buffer on the screen
}

void loop() {
  // Nothing to do here
}

Important Considerations

Troubleshooting and FAQs

Common Issues

  1. The display does not turn on.

    • Verify the power connections (GND and VCC).
    • Ensure the I2C pins (SCL and SDA) are correctly connected to the Arduino.
  2. The display shows random or no data.

    • Check the I2C address of the OLED module. Use an I2C scanner sketch to detect the address.
    • Ensure the required libraries are installed and included in your code.
  3. The text or graphics appear distorted.

    • Call display.clearDisplay() before updating the screen to avoid overlapping data.
    • Verify that the resolution in your code matches the display's resolution (e.g., 128x64).
  4. The display flickers or dims.

    • Check the power supply voltage and current. Insufficient power can cause flickering.
    • Reduce the brightness in your code to lower power consumption.

FAQs

Q: Can I use the OLED display with a 3.3V microcontroller?
A: Yes, most OLED modules are compatible with both 3.3V and 5V systems. Check the module's datasheet to confirm.

Q: How do I display custom graphics or images?
A: You can use tools like the Adafruit ImageConverter (online) to convert images into a bitmap array for use with the Adafruit_GFX library.

Q: Can I use the OLED display with other microcontrollers?
A: Yes, the OLED display can be used with other microcontrollers like ESP32, ESP8266, and Raspberry Pi. Ensure the appropriate libraries and connections are used.

Q: What is the lifespan of an OLED display?
A: The lifespan depends on usage and brightness settings. Typical OLED displays last around 10,000 to 50,000 hours. Lowering brightness can extend the lifespan.