Updated date:

Display Image on OLED Screen Using Arduino

Tim is currently doing research in Internet of Things (IoT). His desire to spread the concept, ideas, and experience of IoT.

display-image-on-oled-screen-using-arduino

The OLED screen which I am using in this tutorial supports 128X64 pixels. There are many OLED screen available in market. I this article I have used OLED 128x64 I2C display SSD1306 which has its screen split in two colors, yellow (16 pixels from top) and sky blue (next 48 pixels).

The following figure shows structure of OLED Screen.

display-image-on-oled-screen-using-arduino

You first need to connect OLED screen to Arduino. Please use following schemetic to connect the screen to Arduino.

display-image-on-oled-screen-using-arduino

The OLED screen is connected to A4 and A5 pins of Arduino as these pins serves as I2C interface.

I2C is Short for Inter-integrated Circuit which is a protocol that allow multiple slave digital integrated circuits (chips) to communicate with one or more master chip. I2C uses two lines to send and receive data i.e. a Serial Clock pin (SCL) and a serial data pin (SDA). Arduino has twice SDA and SCL because A4 can be used as SDA and A5 as SCL.

See following diagram

Recommended Reading


In the example below I am simply displaying Coca Cola logo for five seconds as the Arduino boots and after that a welcome message is displayed. This kind of example can be used when you are making a commercial device and you want to display your company logo as the device boots and after that an interface should be displayed.

Just watch following video.

In following section I'll show you how you can display any image with 128X64 resolution to the OLED display.

To display a logo, a Coca Cola logo in my example, you need an image.

Just do a Google search for Coca Cola image as follows.

display-image-on-oled-screen-using-arduino

save the coca cola image that you like. Now open the Photoshop and create a new image file with 128X64 resolution as follows.

display-image-on-oled-screen-using-arduino

Insert the image that you downloaded in Photoshop and resize it to fit to your 128x64 canvas the go to Mode->Grayscale to convert image to grayscale as shown below.

display-image-on-oled-screen-using-arduino

The image is now converted to grayscale. Save this image as jpg file.

display-image-on-oled-screen-using-arduino

Next open the paintbrush application on windows and in paintbrush application open the jpg file that you just saved. After the file is opened in paint, save it again as monochrome bitmap file using paintbrush as shown below.

display-image-on-oled-screen-using-arduino

The image will be converted to monochrome bitmap as shown below.

display-image-on-oled-screen-using-arduino

Now before we can use this image in our Arduino code in order to display it on OLED display, it should be converted to C Programming array. To do this I am using LCD image converter software.

Open the LCD image converter and create a new image and named it cola as shown below.

display-image-on-oled-screen-using-arduino
display-image-on-oled-screen-using-arduino

After creating the image file, import the cola.bmp bitmap image to LCD image converter image as follows.

display-image-on-oled-screen-using-arduino

The imported image will be shown as below.

display-image-on-oled-screen-using-arduino

Now go to Options->Conversion...

display-image-on-oled-screen-using-arduino

The following dialog box will be shown.

In the following dialog box select Preset as Monochrome and under Prepare tab select type as Monochrome and Threshold Dither, also under Image tab in same dialogbox select Block Size as 8 bit. Follow the instructions in images below.

display-image-on-oled-screen-using-arduino
display-image-on-oled-screen-using-arduino

Go to File->Convert... and save the file as cola.c.

display-image-on-oled-screen-using-arduino
display-image-on-oled-screen-using-arduino

The created cola.c source file looks like following.

display-image-on-oled-screen-using-arduino

The source code of cola.c file is following.

/*******************************************************************************
* image
* filename: unsaved
* name: cola
*
* preset name: Monochrome
* data block size: 8 bit(s), uint8_t
* RLE compression enabled: no
* conversion type: Monochrome, Threshold Dither 128
* bits per pixel: 1
*
* preprocess:
*  main scan direction: top_to_bottom
*  line scan direction: forward
*  inverse: no
*******************************************************************************/

/*
 typedef struct {
     const uint8_t *data;
     uint16_t width;
     uint16_t height;
     uint8_t dataSize;
     } tImage;
*/
#include <stdint.h>

static const uint8_t image_data_cola[1024] = {
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xf0, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xfe, 0x1f, 0xff, 
    0xff, 0xff, 0xfe, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0e, 0x38, 0x07, 0xf8, 0xdf, 0x3f, 
    0xff, 0xff, 0xf8, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x39, 0x3e, 0x03, 0xf1, 0xde, 0x7f, 
    0xff, 0xff, 0xf0, 0x7c, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x73, 0x3f, 0x80, 0xe3, 0xbc, 0xff, 
    0xff, 0xff, 0xe0, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe7, 0x7f, 0xc0, 0xc7, 0xf1, 0xff, 
    0xff, 0xff, 0x83, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xcf, 0x7f, 0xf1, 0x8f, 0x03, 0xff, 
    0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x9e, 0x7f, 0xff, 0x18, 0x0f, 0xff, 
    0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xbe, 0xff, 0xfe, 0x30, 0x3f, 0xff, 
    0xff, 0xfc, 0x0f, 0xf8, 0x7f, 0xc7, 0xf8, 0xc7, 0x1c, 0x1f, 0x3d, 0xff, 0xfc, 0x65, 0xff, 0xff, 
    0xff, 0xf8, 0x1f, 0xe1, 0x3f, 0x0b, 0xf0, 0x0e, 0x18, 0x3f, 0x79, 0xff, 0xf8, 0x7f, 0xff, 0xff, 
    0xff, 0xf0, 0x3f, 0xc7, 0x3e, 0x39, 0xc3, 0x0c, 0x38, 0x7e, 0xf3, 0xff, 0xf0, 0xfb, 0xff, 0xff, 
    0xff, 0xf0, 0x7f, 0x87, 0x3c, 0x73, 0x87, 0x1f, 0xf0, 0x7e, 0xe7, 0xff, 0xf1, 0xf7, 0xff, 0xff, 
    0xff, 0xe0, 0x7f, 0x0f, 0x70, 0xe3, 0x0e, 0x1f, 0xe0, 0xfe, 0x0f, 0xff, 0xe1, 0xe7, 0xff, 0xff, 
    0xff, 0xe0, 0xfe, 0x07, 0x61, 0xc6, 0x1e, 0x3f, 0xc1, 0xff, 0x3f, 0xff, 0xc3, 0xcf, 0xff, 0xff, 
    0xff, 0xc1, 0xfc, 0x32, 0x43, 0xfe, 0x3c, 0x7f, 0x83, 0xff, 0xff, 0xff, 0x87, 0x9f, 0xff, 0xff, 
    0xff, 0x81, 0xf8, 0x7c, 0x03, 0xfc, 0x38, 0x7f, 0x83, 0xff, 0xff, 0xff, 0x8f, 0x3f, 0xff, 0xff, 
    0xff, 0x83, 0xf8, 0x7c, 0xc7, 0xf8, 0x78, 0xff, 0x07, 0xff, 0xff, 0xff, 0x0e, 0x7f, 0xff, 0xff, 
    0xff, 0x03, 0xf0, 0xf9, 0x87, 0xf0, 0xf0, 0xef, 0x07, 0xc3, 0xfe, 0x1f, 0x1c, 0xf1, 0x8f, 0xff, 
    0xff, 0x07, 0xf0, 0xfb, 0x0f, 0xe0, 0xe1, 0xde, 0x0f, 0x89, 0xf8, 0xde, 0x19, 0xc2, 0x0f, 0xff, 
    0xfe, 0x07, 0xe1, 0xf7, 0x0f, 0xe1, 0xe3, 0xbe, 0x0e, 0x1d, 0xf1, 0xcc, 0x37, 0x86, 0x1f, 0xff, 
    0xfe, 0x0f, 0xe1, 0xe7, 0x0f, 0xc1, 0xc3, 0x3c, 0x1e, 0x3d, 0xe3, 0xdc, 0x2f, 0x0e, 0x3f, 0xff, 
    0xfe, 0x0f, 0xe1, 0xce, 0x1f, 0x81, 0x86, 0x7c, 0x1c, 0x7d, 0xc3, 0xd8, 0x1e, 0x1c, 0x3f, 0xff, 
    0xfe, 0x0f, 0xe0, 0x9e, 0x0e, 0x61, 0x04, 0xf8, 0x38, 0x79, 0x81, 0xd8, 0x3c, 0x38, 0x7f, 0xff, 
    0xfe, 0x1f, 0xe0, 0x3e, 0x00, 0xc0, 0x01, 0xf8, 0x38, 0x7b, 0x0c, 0xb0, 0xf8, 0x78, 0xff, 0xff, 
    0xfe, 0x1f, 0xe0, 0x7f, 0x03, 0xc1, 0x87, 0xf0, 0x78, 0xfb, 0x1e, 0x00, 0xf8, 0xf0, 0xff, 0xff, 
    0xfe, 0x1f, 0xf1, 0xff, 0x87, 0xe3, 0xcf, 0xf0, 0x73, 0xf6, 0x1f, 0x61, 0xf0, 0xf1, 0xff, 0xff, 
    0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x77, 0xe6, 0x3e, 0x61, 0xe1, 0xe1, 0xdf, 0xff, 
    0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xec, 0x3e, 0xe1, 0xe1, 0xc3, 0xbf, 0xff, 
    0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xdc, 0x7d, 0xc3, 0xc3, 0xc7, 0x7f, 0xff, 
    0xfe, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf0, 0x7f, 0x98, 0x79, 0xc3, 0x83, 0x86, 0x7f, 0xff, 
    0xfe, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xf0, 0x7f, 0x38, 0x73, 0xc3, 0x03, 0x0c, 0xff, 0xff, 
    0xff, 0x03, 0xff, 0xc0, 0x7c, 0x00, 0x0f, 0xf8, 0x3c, 0x78, 0x07, 0xc2, 0x00, 0x01, 0xff, 0xff, 
    0xff, 0x80, 0xf8, 0x1f, 0xff, 0x00, 0x03, 0xf8, 0x01, 0xf8, 0x0f, 0xc0, 0x81, 0x03, 0xff, 0xff, 
    0xff, 0xe0, 0x01, 0xff, 0xff, 0xc7, 0xf9, 0xfc, 0x03, 0xf8, 0x3f, 0xc1, 0x83, 0x0f, 0xff, 0xff, 
    0xff, 0xfc, 0x7f, 0xff, 0xff, 0xef, 0xfe, 0xff, 0x1f, 0xfc, 0xff, 0xe7, 0xef, 0x9f, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const tImage cola = { image_data_cola, 128, 64, 8 };

We will use the array initialization from above C source file into our Arduino code below.

Now copy the following Arduino code and compile & upload it to your Arduino board which has OLED display connected.

Arduino Code

#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);

static const unsigned char PROGMEM image_data_Cola[] = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xf0, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xfe, 0x1f, 0xff, 
    0xff, 0xff, 0xfe, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0e, 0x38, 0x07, 0xf8, 0xdf, 0x3f, 
    0xff, 0xff, 0xf8, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x39, 0x3e, 0x03, 0xf1, 0xde, 0x7f, 
    0xff, 0xff, 0xf0, 0x7c, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x73, 0x3f, 0x80, 0xe3, 0xbc, 0xff, 
    0xff, 0xff, 0xe0, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe7, 0x7f, 0xc0, 0xc7, 0xf1, 0xff, 
    0xff, 0xff, 0x83, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xcf, 0x7f, 0xf1, 0x8f, 0x03, 0xff, 
    0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x9e, 0x7f, 0xff, 0x18, 0x0f, 0xff, 
    0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0f, 0xbe, 0xff, 0xfe, 0x30, 0x3f, 0xff, 
    0xff, 0xfc, 0x0f, 0xf8, 0x7f, 0xc7, 0xf8, 0xc7, 0x1c, 0x1f, 0x3d, 0xff, 0xfc, 0x65, 0xff, 0xff, 
    0xff, 0xf8, 0x1f, 0xe1, 0x3f, 0x0b, 0xf0, 0x0e, 0x18, 0x3f, 0x79, 0xff, 0xf8, 0x7f, 0xff, 0xff, 
    0xff, 0xf0, 0x3f, 0xc7, 0x3e, 0x39, 0xc3, 0x0c, 0x38, 0x7e, 0xf3, 0xff, 0xf0, 0xfb, 0xff, 0xff, 
    0xff, 0xf0, 0x7f, 0x87, 0x3c, 0x73, 0x87, 0x1f, 0xf0, 0x7e, 0xe7, 0xff, 0xf1, 0xf7, 0xff, 0xff, 
    0xff, 0xe0, 0x7f, 0x0f, 0x70, 0xe3, 0x0e, 0x1f, 0xe0, 0xfe, 0x0f, 0xff, 0xe1, 0xe7, 0xff, 0xff, 
    0xff, 0xe0, 0xfe, 0x07, 0x61, 0xc6, 0x1e, 0x3f, 0xc1, 0xff, 0x3f, 0xff, 0xc3, 0xcf, 0xff, 0xff, 
    0xff, 0xc1, 0xfc, 0x32, 0x43, 0xfe, 0x3c, 0x7f, 0x83, 0xff, 0xff, 0xff, 0x87, 0x9f, 0xff, 0xff, 
    0xff, 0x81, 0xf8, 0x7c, 0x03, 0xfc, 0x38, 0x7f, 0x83, 0xff, 0xff, 0xff, 0x8f, 0x3f, 0xff, 0xff, 
    0xff, 0x83, 0xf8, 0x7c, 0xc7, 0xf8, 0x78, 0xff, 0x07, 0xff, 0xff, 0xff, 0x0e, 0x7f, 0xff, 0xff, 
    0xff, 0x03, 0xf0, 0xf9, 0x87, 0xf0, 0xf0, 0xef, 0x07, 0xc3, 0xfe, 0x1f, 0x1c, 0xf1, 0x8f, 0xff, 
    0xff, 0x07, 0xf0, 0xfb, 0x0f, 0xe0, 0xe1, 0xde, 0x0f, 0x89, 0xf8, 0xde, 0x19, 0xc2, 0x0f, 0xff, 
    0xfe, 0x07, 0xe1, 0xf7, 0x0f, 0xe1, 0xe3, 0xbe, 0x0e, 0x1d, 0xf1, 0xcc, 0x37, 0x86, 0x1f, 0xff, 
    0xfe, 0x0f, 0xe1, 0xe7, 0x0f, 0xc1, 0xc3, 0x3c, 0x1e, 0x3d, 0xe3, 0xdc, 0x2f, 0x0e, 0x3f, 0xff, 
    0xfe, 0x0f, 0xe1, 0xce, 0x1f, 0x81, 0x86, 0x7c, 0x1c, 0x7d, 0xc3, 0xd8, 0x1e, 0x1c, 0x3f, 0xff, 
    0xfe, 0x0f, 0xe0, 0x9e, 0x0e, 0x61, 0x04, 0xf8, 0x38, 0x79, 0x81, 0xd8, 0x3c, 0x38, 0x7f, 0xff, 
    0xfe, 0x1f, 0xe0, 0x3e, 0x00, 0xc0, 0x01, 0xf8, 0x38, 0x7b, 0x0c, 0xb0, 0xf8, 0x78, 0xff, 0xff, 
    0xfe, 0x1f, 0xe0, 0x7f, 0x03, 0xc1, 0x87, 0xf0, 0x78, 0xfb, 0x1e, 0x00, 0xf8, 0xf0, 0xff, 0xff, 
    0xfe, 0x1f, 0xf1, 0xff, 0x87, 0xe3, 0xcf, 0xf0, 0x73, 0xf6, 0x1f, 0x61, 0xf0, 0xf1, 0xff, 0xff, 
    0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x77, 0xe6, 0x3e, 0x61, 0xe1, 0xe1, 0xdf, 0xff, 
    0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xec, 0x3e, 0xe1, 0xe1, 0xc3, 0xbf, 0xff, 
    0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xdc, 0x7d, 0xc3, 0xc3, 0xc7, 0x7f, 0xff, 
    0xfe, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xf0, 0x7f, 0x98, 0x79, 0xc3, 0x83, 0x86, 0x7f, 0xff, 
    0xfe, 0x07, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xf0, 0x7f, 0x38, 0x73, 0xc3, 0x03, 0x0c, 0xff, 0xff, 
    0xff, 0x03, 0xff, 0xc0, 0x7c, 0x00, 0x0f, 0xf8, 0x3c, 0x78, 0x07, 0xc2, 0x00, 0x01, 0xff, 0xff, 
    0xff, 0x80, 0xf8, 0x1f, 0xff, 0x00, 0x03, 0xf8, 0x01, 0xf8, 0x0f, 0xc0, 0x81, 0x03, 0xff, 0xff, 
    0xff, 0xe0, 0x01, 0xff, 0xff, 0xc7, 0xf9, 0xfc, 0x03, 0xf8, 0x3f, 0xc1, 0x83, 0x0f, 0xff, 0xff, 
    0xff, 0xfc, 0x7f, 0xff, 0xff, 0xef, 0xfe, 0xff, 0x1f, 0xfc, 0xff, 0xe7, 0xef, 0x9f, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
    };
 
void setup() {
  Serial.begin(115200);
 
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000); // Pause for 2 seconds
 
  // Clear the buffer.
  display.clearDisplay();
  
  // Draw bitmap on the screen
  display.drawBitmap(0, 0, image_data_Cola, 128, 64, 1);
  display.display();
  delay(5000);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 1);
  display.println("Welcome to CocaCola.");
  display.display();
  
}
 
void loop() {
  
}

The following output will be displayed

display-image-on-oled-screen-using-arduino
display-image-on-oled-screen-using-arduino

Just try my another example given below. I will show you how you can display simple text and image together at different coordinates.

For this example I have created a battery image of 20x10 pixels with white foreground and black background.

Second Example Code

#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);

static const unsigned char PROGMEM image_data_battery[] = {
    0x1f, 0xff, 0xc0, 
    0x20, 0x00, 0x20, 
    0x20, 0x0d, 0xa0, 
    0xe0, 0x0d, 0xa0, 
    0x80, 0x0d, 0xa0, 
    0xe0, 0x0d, 0xa0, 
    0x20, 0x0d, 0xa0, 
    0x20, 0x00, 0x20, 
    0x1f, 0xff, 0xc0, 
    0x00, 0x00, 0x00
    };

void setup() {
  Serial.begin(115200);
 
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000); // Pause for 2 seconds
 
  // Clear the buffer.
  display.clearDisplay();
  
  // Draw bitmap on the screen
 
 display.drawBitmap(108, 0, image_data_battery, 20, 10, 1);
  
 display.setTextSize(1);
 display.setTextColor(WHITE);
 display.setCursor(0, 0);
 display.println("3:50PM");
 display.setTextSize(2);
 display.setTextColor(WHITE);
 display.setCursor(20, 25);
 display.print("Welcome");
 display.setTextSize(1);
 display.setTextColor(WHITE);
 display.setCursor(20, 45);
 display.print("Arduino Is Fun");
 display.display();
}
 
void loop() {
 
}

Following will be the output of above code.

display-image-on-oled-screen-using-arduino

This article is inspired by OLED Guide by RandomNerdTutorials. For more details on installing libraries and different library functions to draw text, shapes and images please visit Guide for I2C OLED Display with Arduino.