HomeArduino TutorialsArduino Displays & InterfacesArduino SSD1306 OLED 0.96″ Display Guide – Show Text, Numbers & Custom Animations

Interfacing SSD1306 OLED Display (0.96”) with Arduino using I2C

The SSD1306 OLED Display is one of the most popular screens used with Arduino for showing text, numbers, and simple graphics. This tiny 0.96-inch display uses the I2C communication protocol, which means it only needs two wires, SDA and SCL, to connect with the Arduino.

In this tutorial, you’ll learn how to interface the SSD1306 OLED display with Arduino and display various types of data such as text, integers, and floating-point numbers. We’ll also go a step further and explore how to display animations and create your own custom animated graphics on the OLED screen.

Prerequisites:

Along with some basic knowledge of Arduino, you should also take a look at the Arduino I2C Tutorial covered a while back. This will help you understand the concept with much more clarity.

Interfacing SSD1306 OLED Display (0.96”) with Arduino using I2C

Introduction to SSD1306 OLED Display

What is the SSD1306 Display?

The SSD1306 OLED display is a small yet powerful screen commonly used in embedded electronics projects. It’s based on an OLED (Organic Light Emitting Diode) panel, where each pixel emits its own light. This means there’s no need for a backlight, resulting in deep blacks, high contrast, and excellent visibility even in low light conditions.

The display is controlled by the SSD1306 driver IC, which handles communication with the microcontroller through interfaces like I2C or SPI. In this tutorial, we’ll focus on the I2C version, which uses just two data lines, SDA (Serial Data) and SCL (Serial Clock), making it ideal for projects with limited I/O pins.

Thanks to its compact size and low power consumption, the SSD1306 OLED display is a perfect choice for showing text, sensor readings, or small graphics in Arduino-based projects.


OLED Display Specifications and Features

The 0.96-inch SSD1306 OLED display is packed with useful features despite its small footprint. Below are the most common specifications you’ll find:

  • Display Size: 0.96 inches (measured diagonally)
  • Resolution: 128 × 64 pixels
  • Driver IC: SSD1306
  • Interface Type: I2C (can also be SPI on some modules)
  • Operating Voltage: 3.3V to 5V
  • Power Consumption: Very low, since OLEDs emit their own light
  • Viewing Angle: Nearly 180 degrees
  • Color: Typically monochrome (white, blue, or yellow variants available)
Logo Bitmap being printed on the 0.96" SSD1306 Oled display with Arduino.

Each pixel on the OLED can be individually turned on or off, allowing you to display text, numbers, bitmaps, and simple animations. The high contrast ratio gives sharp and clear visuals, which makes it perfect for small handheld devices, IoT dashboards, or portable meters.


Why Use SSD1306 with Arduino?

There are several reasons why the SSD1306 OLED display is one of the most popular choices among Arduino enthusiasts:

  • Simple Interface: Using the I2C protocol reduces wiring to just two pins, making it beginner-friendly and easy to integrate.
  • Excellent Display Quality: OLED technology provides bright, high-contrast output with minimal power consumption.
  • Compact and Lightweight: Ideal for small enclosures or battery-powered projects.
  • Wide Library Support: The display is supported by popular libraries like Adafruit SSD1306 and Adafruit GFX, making programming effortless.
  • Versatile Usage: From showing text and sensor values to creating cool startup animations, the SSD1306 can handle it all.

Components and Circuit Connection

Required Components

Before connecting the OLED to Arduino, let’s gather all the components you’ll need for this project. The list is short, and all parts are easily available online or in local electronics stores.

You’ll need:

  • Arduino Board – You can use Arduino Uno, Nano, or Mega (any board with I2C support will work).
  • SSD1306 OLED Display (0.96″) – Make sure it’s the I2C version with four pins: GND, VCC, SDA, and SCL.
  • Jumper Wires – For making connections between Arduino and OLED.
  • Breadboard – Optional, but helpful for easy prototyping and testing.

That’s all you need! The hardware setup is very simple, which makes this project perfect for beginners who are learning about I2C communication with Arduino.


Wiring SSD1306 OLED Display to Arduino (I2C Pins)

The I2C version of the SSD1306 display uses just two signal lines to communicate with Arduino, SDA (data line) and SCL (clock line). Along with these, you also need to connect power and ground.

The image below shows how the 0.96″ SSD1306 Oled display is connected to Arduino UNO.

Arduino Uno and 0.96" Oled SSD1306 wiring diagram using I2C.

Here’s how to connect it:

OLED PinConnects ToDescription
VCC5V (or 3.3V on some models)Power supply for the display
GNDGNDCommon ground
SDAA4 (on Arduino Uno/Nano)I2C Data line
SCLA5 (on Arduino Uno/Nano)I2C Clock line

Tip: On the Arduino Mega, the I2C pins are SDA = Pin 20 and SCL = Pin 21. On newer boards like Arduino Leonardo, they are marked separately as SDA/SCL pins.

Once connected, your OLED display will communicate with Arduino over the I2C bus. The display typically uses the I2C address 0x3C, but some modules may use 0x3D — you can verify it using an I2C scanner sketch.


Finding the I2C Address of Your Oled

To find your Oled I2C address, you can run a simple I2C scanner sketch on your Arduino:

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Scanning for I2C devices...");
  for (byte i = 1; i < 127; i++) {
    Wire.beginTransmission(i);
    if (Wire.endTransmission() == 0) {
      Serial.print("I2C device found at address 0x");
      Serial.println(i, HEX);
    }
  }
}

void loop() {}

Upload this code to your Arduino and open the Serial Monitor. You’ll see the detected I2C address printed there.

The image below shows the result of the I2C scanner code.

Arduino I2C Scanner found the address of SSD1306 Oled display connected via I2C.

You can see the address 0x3C is detected by the scanner. We will use this address in our code later.


Common Connection Mistakes and How to Avoid Them

Even though the wiring is simple, there are a few common issues beginners often face. Here’s how to avoid them:

  • Reversed Power Connections: Double-check the VCC and GND lines. Reversing them can damage the OLED permanently.
  • Wrong Voltage: Some displays only support 3.3V, while others accept 5V. Always verify the voltage rating printed on your module before powering it up.
  • Incorrect SDA and SCL Pins: Using the wrong pins for I2C communication will prevent the display from responding. Check your Arduino board’s pinout.
  • Loose or Poor Connections: Ensure all jumper wires are firmly connected, especially when using a breadboard.
  • Wrong I2C Address: If the display doesn’t show anything, try running an I2C scanner sketch to detect its correct address (0x3C or 0x3D).

Following these steps carefully will ensure a reliable connection between the SSD1306 OLED and your Arduino, so you can move on to programming the display without any issues.

Setting Up the Arduino IDE for SSD1306

Once the hardware connection is done, the next step is to prepare your Arduino IDE so that it can communicate with the SSD1306 OLED display. We’ll use two official libraries from Adafruit that make working with the OLED display very simple — the Adafruit SSD1306 library and the Adafruit GFX library.

Installing Adafruit SSD1306 and GFX Libraries

To begin, open your Arduino IDE and follow these steps:

  1. Go to the Sketch menu → Include LibraryManage Libraries…
  2. In the Library Manager, type “SSD1306” in the search bar.
  3. Find Adafruit SSD1306 by Adafruit and click Install.
  4. Next, search for “Adafruit GFX” and install Adafruit GFX Library as well.
Install Adafruit SSD1306 library on Arduino
Install Adafruit GFX library on Arduino

These two libraries work together, the SSD1306 library handles communication with the display, while the GFX library provides all the basic drawing functions such as drawing shapes, text, and bitmaps.

Tip: Always install the latest versions of these libraries to ensure compatibility and bug fixes. If you already have older versions installed, update them through the Library Manager.

After installing both libraries, you’ll have access to multiple example sketches that demonstrate how to use the OLED display effectively.


Understanding the Display Address (0x3C vs 0x3D)

Every I2C device has a unique address that allows the Arduino to identify it on the I2C bus. The SSD1306 OLED module typically uses one of two possible I2C addresses, 0x3C or 0x3D.

The exact address depends on your display module’s configuration and manufacturer. Some modules have a small solder bridge or jumper that lets you switch between these two addresses.

If your OLED display doesn’t show anything when you upload the example code, the most likely reason is a wrong I2C address. You can easily check this by running an I2C Scanner Sketch. It will print the detected I2C addresses on the Serial Monitor, helping you confirm whether your display is 0x3C or 0x3D.

Note: The Adafruit example sketches use 0x3C by default, which works for most OLED displays.


Running the First Example Sketch

Now that everything is set up, let’s test the OLED display with a ready-made example.

  1. Open Arduino IDE and go to File → Examples → Adafruit SSD1306 → ssd1306_128x64_i2c.
  2. The example code includes the display setup and some demo text and graphics.
  3. In the code, find this line and ensure the I2C address matches your module: #define SCREEN_ADDRESS 0x3C Change it to 0x3D if your display uses that address.
  4. Select the correct board and COM port, then click Upload.
Adafruit ssd1306 128x64 i2c oled example for arduino

If everything is connected correctly, you should see the Adafruit logo appear first, followed by scrolling text and simple animations. This confirms that your display and Arduino are communicating successfully.

0.96" SSD1306 Oled display showing the Adafruit Logo

Tip: If you still see a blank screen, double-check your I2C connections, address, and power supply.

With this test complete, your setup is ready for custom code — you can now display your own text, numbers, and even animations on the OLED display.

Displaying Text on the SSD1306 OLED

Once the OLED display is working with the test sketch, the next step is to learn how to display your own text messages. The Adafruit GFX library provides simple and flexible functions to print text in different styles, sizes, and positions on the screen. This makes it easy to show messages, sensor readings, or any kind of data from your Arduino project.

Printing Simple Text Messages

To print basic text on the SSD1306 OLED display, you first need to include the required libraries and initialize the display in your Arduino sketch.
Here’s a simple example:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 10);
  display.print("Hello, World!");
  display.display();
}

void loop() {
}

Here’s what’s happening in this code:

  • display.clearDisplay() clears any previous content on the screen.
  • display.setTextSize(1) sets the default font size.
  • display.setTextColor(SSD1306_WHITE) makes the text white on a black background.
  • display.setCursor(0, 10) sets the text starting position in pixels.
  • display.print("Hello, World!"); prints the message on the display.
  • Finally, display.display() sends everything from memory to the OLED screen.

Tip: The display only updates when you call display.display(). This helps reduce flicker and gives you control over when to refresh the screen.


The image below shows the output of the code on the oled display.

0.96" SSD1306 Oled display showing the text printed on it.

Adjusting Font Size and Cursor Position

You can change the font size and cursor position easily using the Adafruit GFX functions. This is useful when you want to show headings, highlight values, or neatly arrange multiple text elements.

For example:

display.clearDisplay();
display.setTextSize(2);     // Larger text
display.setCursor(20, 20);  // Move text to new position
display.print("Arduino");
display.display();
  • The setTextSize() function accepts integer values.
    • Size 1 is the smallest,
    • Size 2 is double, and so on.
  • The setCursor(x, y) function positions the text where x is the horizontal position and y is the vertical one.
0.96" SSD1306 Oled display showing the text printed on it.

You can experiment with different positions and sizes to make your display layout look more professional and easy to read.


Using Text Wrapping and Inversion

The Adafruit GFX library also includes options for text wrapping and inverting colors, which can enhance your display output.

  • Text Wrapping:
    By default, the library automatically wraps text when it reaches the edge of the display.
    You can disable this behavior with: display.setTextWrap(false); This is useful when you want full control over text placement without automatic line breaks.
  • Inverted Text:
    To make text stand out, you can invert the colors. This switches the text color to black on a white background. display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); The first parameter sets the text color, and the second defines the background color.

Combining these features allows you to design dynamic and readable text layouts — for example, highlighting headings, displaying sensor names, or showing warnings on your OLED display.

Displaying Numbers and Floating Values

Printing numbers on the SSD1306 OLED display is just as easy as printing text. Whether you want to show sensor readings, counter values, or real-time measurements, the Adafruit GFX library provides simple methods to print both integers and floating-point numbers. You can even combine them with text for clear and informative displays.

Displaying Integer Values

To display integer values, you can directly use the display.print() or display.println() functions — just like you would use with the Serial Monitor.

Here’s a simple example that shows a counter increasing every second:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int counter = 0;

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(SSD1306_WHITE);
}

void loop() {
  display.clearDisplay();
  display.setCursor(10, 20);
  display.print("Count: ");
  display.print(counter);
  display.display();
  counter++;
  delay(1000);
}

In this example:

  • The variable counter increases by 1 every second.
  • display.print(counter); shows the current count value.
  • Each time the display is updated, it clears the previous value to prevent overlapping text.

Tip: If you forget to use display.clearDisplay(), the old numbers might overlap with the new ones, making the display unreadable.

The gif below shows the output of the code.

Numbers being printed on the 0.96" SSD1306 Oled display with Arduino.

Printing Floating Point Numbers with Precision

The Adafruit GFX library also allows you to display floating-point numbers directly using display.print(). You can control the number of decimal places by passing a second parameter to the print() function.

Example:

float temperature = 25.6789;

display.clearDisplay();
display.setCursor(10, 20);
display.setTextSize(2);
display.print("Temp: ");
display.print(temperature, 2);  // prints 25.68
display.display();

In the line display.print(temperature, 2);, the number 2 specifies that only two digits after the decimal point should be shown.
You can adjust this value depending on the precision you need — for example, use (temperature, 1) for one decimal place or (temperature, 3) for three.

This feature is very helpful for displaying sensor values such as temperature, voltage, or humidity, where accurate decimal representation is needed.

Note: Avoid using too many decimal places because the OLED has limited space and smaller fonts may become hard to read.

The image below shows the float number displaying on the Oled.

Float Numbers being printed on the 0.96" SSD1306 Oled display with Arduino.

Displaying Bitmaps on SSD1306 Oled

One of the best features of the SSD1306 OLED display is its ability to show custom graphics and logos. You can easily display icons, images, or even full-screen logos by using bitmap arrays. This opens up endless possibilities — from startup screens and battery indicators to creative graphics for your Arduino projects.

In this section, you’ll learn how to display static and dynamic bitmaps on your OLED using the Adafruit SSD1306 and Adafruit GFX libraries.

Understanding Bitmaps on OLED Displays

A bitmap is a collection of binary data that represents each pixel on the screen.

  • Each bit in the array corresponds to one pixel.
  • A value of 1 means the pixel is turned ON (white), while 0 means it’s OFF (black).
  • Since the SSD1306 display is monochrome, there are no shades or colors — only black and white pixels.

You can use bitmaps to display small icons (like a Wi-Fi or battery symbol) or full-screen logos for branding your project.

Example of a simple 8×8 pixel bitmap:

const unsigned char myBitmap[] PROGMEM = {
  0x3C, 0x42, 0xA9, 0x85, 0xA9, 0x91, 0x42, 0x3C
};

Here, each byte represents 8 pixels, and the pattern defines the shape to be displayed.


Converting Images to Bitmaps

To use your own image, you need to convert it into a C byte array. You can easily do this using the Image2CPP online tool.

The image below shows how to create bitmap using an existing image.

create bitmap using an existing image using Image2CPP tool.

Follow these steps:

  1. Create a simple black-and-white image (for example, your logo).
  2. Upload it in Image2CPP.
  3. Configure the Image Settings. You can check the preview to see how the final image will look.
  4. Adjust the brightness/alpha threshold to generate clear image.
  5. Set output as Arduino Code.
  6. Choose Monochrome and Horizontal byte orientation.
  7. Click Generate Code and copy the byte array.

After copying the byte array, paste it in a new header file. It will keep the code clean as our image data will be in a separate file. In the image below, I have created a separate file named logo.h.

create a separate header file to store the bitmap byte array.

Now copy the file to the Arduino project folder, so that we can use it in the code.

copy the bitmap header file to the arduino project folder.

Displaying a Bitmap Using Adafruit Library

To show your bitmap on the OLED, include the bitmap header file in the main file. Then use the drawBitmap() function provided by the Adafruit GFX library.

Here’s a simple example:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "logo.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.drawBitmap(32, 0, myBitmap, 64, 64, SSD1306_WHITE);
  display.display();
}

void loop() {
}

In the above code:

  • #include "logo.h" will include the bitmap header file.
  • drawBitmap() draws the image starts at position (32, 0).
  • The parameters (64, 64) specify the width and height of the image.
  • SSD1306_WHITE turns the pixels ON.

You can adjust the x and y positions to move the image anywhere on the screen.


The image below shows the output of the above code. You can see the ControllersTech Logo is being displayed on the oled.

Logo Bitmap being printed on the 0.96" SSD1306 Oled display with Arduino.

Combining Text and Bitmaps

You can mix text and graphics to make your OLED display more interactive. For example, show a Wi-Fi icon beside connection status text, or a battery symbol next to voltage readings.

Example:

display.drawBitmap(0, 0, wifiIcon, 16, 16, SSD1306_WHITE);
display.setCursor(20, 5);
display.setTextSize(1);
display.print("Connected");
display.display();

This way, your display can look more professional, just like a mini dashboard interface.


Best Practices for Using Bitmaps

  • Always clear the display before drawing new images: display.clearDisplay();
  • Use small icons (16×16, 32×32) for faster rendering.
  • Store all bitmap data in PROGMEM to reduce RAM usage.
  • Test image alignment by adjusting x and y coordinates.
  • Avoid too many large bitmaps to prevent memory overflow.

Creating Animations on SSD1306

The SSD1306 OLED display isn’t just for showing text and numbers — it’s also great for creating small, eye-catching animations. Whether you want to show a loading spinner, a bouncing object, or a moving logo, the Adafruit GFX library makes it possible by quickly updating frames on the screen.

In this section, we’ll understand how OLED animation works, how to use bitmap images, and how to design simple frame-based animations like a bouncing ball.

Understanding Frame Updates and Delays

Animations on OLED displays work by displaying a sequence of frames very quickly, just like a flipbook. Each frame represents one stage of motion. When frames change fast enough, the human eye perceives smooth movement.

The key steps are:

  1. Clear the display (display.clearDisplay())
  2. Draw new graphics or text for the next frame
  3. Show the frame (display.display())
  4. Add a small delay before updating the next frame

Here’s a simple structure for smooth animation:

display.clearDisplay();
display.drawCircle(x, y, 3, SSD1306_WHITE);
display.display();
delay(30);

Each time the loop runs, you update the position (x and y) of the object. The shorter the delay, the smoother the animation — but too short a delay can make the motion too fast or flickery.

Tip: A delay between 20 to 50 milliseconds usually gives smooth animation without overloading the Arduino.


Example: Bouncing Ball Animation

Here’s a fun example — a small bouncing ball animation on the SSD1306 display:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int x = 10, y = 10;
int xSpeed = 2, ySpeed = 2;

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
}

void loop() {
  display.clearDisplay();

  // Draw ball
  display.fillCircle(x, y, 3, SSD1306_WHITE);

  // Update position
  x += xSpeed;
  y += ySpeed;

  // Bounce from edges
  if (x <= 3 || x >= SCREEN_WIDTH - 3) xSpeed = -xSpeed;
  if (y <= 3 || y >= SCREEN_HEIGHT - 3) ySpeed = -ySpeed;

  display.display();
  delay(20);
}

How it works:

  • The ball moves by updating its position in each loop.
  • When it reaches a boundary, its speed reverses direction — creating a bouncing effect.
  • The short delay of 20 ms keeps the animation smooth and steady.

The gif below shows the animation on the bitmap.

Bouncing ball animation on the ssd1306 oled with Arduino.

This simple logic can be expanded to make more complex motions, such as multiple bouncing objects, logos, or even animated characters.


Tips for Smooth OLED Animations

Creating fluid animations on a small display like the SSD1306 requires efficient coding. Here are some useful tips:

  • Keep frame updates minimal: Only redraw what changes, instead of clearing and redrawing everything each time.
  • Reduce delay: Smaller delays make animations smoother but increase CPU usage — find a balance between speed and performance.
  • Optimize bitmap size: Large bitmaps slow down rendering. Stick to small images for best results.
  • Use loops efficiently: Avoid unnecessary calculations inside your loop. Keep only the motion logic.
  • Manage power wisely: OLEDs consume power when pixels are ON. Dim or turn off unused sections to save energy.

By combining these tips, you can design creative and professional-looking animations on your Arduino SSD1306 OLED display, from simple loaders to fun startup sequences or sensor motion effects.

How to Create Your Own Animations

Creating your own custom animations on the SSD1306 OLED display is one of the most exciting parts of using this module. You can design unique motion effects, such as moving icons, rotating logos, or sensor-based visualizations, by displaying a series of bitmap frames in quick succession.

In this section, we’ll go step by step through the process of designing, converting, and displaying your own animation frames on the OLED screen.

Converting Images to Bitmaps

To display any custom animation, you first need to convert your images into bitmap arrays that Arduino can understand. Since the SSD1306 is a monochrome display, all images must be black and white.

You can follow the process of converting image to Bitmap mentioned above. To simulate an animation, you need to convert multiple frames and save them different header files, for example, frame1.h, frame2.h, frame3.h etc.


Displaying Custom Frames in a Loop

Once you’ve converted your images, it’s time to display them in sequence to form an animation.

Here’s an example of how to loop through several bitmap frames:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#include "frame1.h"
#include "frame2.h"
#include "frame3.h"

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
}

void loop() {
  display.clearDisplay();
  display.drawBitmap(0, 0, frame1, 64, 32, SSD1306_WHITE);
  display.display();
  delay(100);

  display.clearDisplay();
  display.drawBitmap(0, 0, frame2, 64, 32, SSD1306_WHITE);
  display.display();
  delay(100);

  display.clearDisplay();
  display.drawBitmap(0, 0, frame3, 64, 32, SSD1306_WHITE);
  display.display();
  delay(100);
}

Each frame is drawn and displayed for a short duration (100 ms here) before switching to the next. Adjusting the delay changes the animation speed — shorter delays result in smoother motion.

Tip: If your animation loops endlessly, you can use sensor inputs or button presses to trigger it at specific times (for example, when a sensor reading crosses a threshold).


Combining Multiple Frames for Motion Effect

To make your animation look more natural, use more frames with slight differences between them. For example, a rotating fan can be drawn in 4 or 6 positions to create the illusion of spinning.

You can store all your frames in an array and loop through them programmatically instead of repeating code blocks.

Example: In this example, I am using cat eye animation. I use this gif to extract the individual frames and then converted them to arrays.

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "cat_animation.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
}

void loop() {
    for (int i = 0; i < 3; i++) {
    display.clearDisplay();
    display.drawBitmap(0, 0, cat_allArray[i], 128, 64, SSD1306_WHITE);
    display.display();
    delay(80); // frame delay for blinking effect
  }
}

The gif below shows the animation on the Oled Display.

Cat eyes animation on SSD1306 oled with Arduino

Troubleshooting and Common Issues

When working with the SSD1306 OLED display, you might face a few common problems such as the screen not turning on, displaying garbage data, or showing nothing at all. Let’s look at the most likely causes and how to fix them.

OLED Not Displaying Anything

If your OLED stays blank after uploading the sketch, don’t worry — this is a very common issue.
Start by checking these points:

  • Power and Ground: Ensure that VCC and GND pins are properly connected. Reversed connections can permanently damage the display.
  • Contrast setting: Some libraries allow you to set the display contrast. If it’s too low, the screen may appear blank.
  • Initialization: Verify that you are calling display.begin(SSD1306_SWITCHCAPVCC, 0x3C) with the correct address.
  • Faulty Display: Try uploading a known working example (like the Adafruit “ssd1306_128x64_i2c” demo) to confirm the OLED module is functional.

Checking I2C Connections and Address

If the OLED isn’t responding, the issue might be related to I2C wiring or the wrong I2C address.

  • SDA and SCL Pins: Double-check that you are using the correct I2C pins for your Arduino board.
    • For most Arduino Uno boards → SDA = A4 and SCL = A5.
    • For Arduino Mega → SDA = 20 and SCL = 21.
  • Run an I2C Scanner: Upload the “I2C Scanner” sketch to detect connected devices. The display usually shows up as 0x3C or 0x3D.
  • Loose Wires: Use short jumper cables and ensure tight breadboard connections. Noise or poor contact can cause intermittent display issues.

Library Conflicts and Reset Problems

Sometimes, using multiple OLED or GFX libraries can cause conflicts during compilation or prevent the display from initializing correctly.

  • Avoid duplicates: Only keep one version each of the Adafruit SSD1306 and Adafruit GFX libraries installed.
  • Clear or reinstall libraries: Delete old versions and reinstall them using the Library Manager.
  • Add a reset delay: If your OLED initializes too quickly after power-up, add a short delay before calling display.begin(). This ensures the internal power circuit stabilizes before communication begins.
  • Test with basic examples: If custom code fails, try a simple “Hello, World” example from the Adafruit library to verify the display setup.

Conclusion

Working with the SSD1306 OLED display is a rewarding experience for any beginner or intermediate Arduino enthusiast. It allows you to visualize data, text, and graphics in a compact and elegant way. Throughout this tutorial, we explored everything from the basic wiring and setup to displaying text, numbers, and even creating fun animations like the Pac-Man example. These small OLED modules are not only easy to use but also versatile, making them ideal for dashboards, sensor displays, clocks, or creative projects like animated characters.

Now that you’re familiar with how to control the SSD1306, you can take your projects a step further by experimenting with dynamic visuals, custom fonts, or even combining multiple OLEDs for more complex interfaces. You can also integrate sensors, Wi-Fi modules, or real-time data to make your OLED projects interactive and intelligent. The possibilities are endless—so go ahead and make your next Arduino project truly come alive on this tiny but powerful display.

Browse More Arduino Display Tutorials

Arduino SSD1306 Oled Project Download

Info

You can help with the development by DONATING Below.
To download the project, click the DOWNLOAD button.

Arduino SSD1306 Oled FAQs

Subscribe
Notify of

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments