Generating Bitmaps in OLED — SSD1306 display using MATLAB

This blog post is intended to help users to generate Bitmaps compatible with 0.96 inch OLED display which can be purchased from the following link.

We developed a Matlab program to use generate 128*64 sized bitmap image to Hex converter which can be used to generate header file for showing the bitmap in the OLED screen. The resultant header contains 1024 bytes of 1D array which can be uploaded to the SSD1306 using simple looping.

The tool can be downloaded from the below links.

Sample codes for Arduino, PIC, and AVR can be found from the below links.

ARDUINO Sample Code

PIC Sample Code

AVR Sample Code

Use the sample codes to get started to show bitmaps of your choice.

Using MATLAB program to generate the Bitmap

Run MATLAB program hex_create.m’ with the intended image in the same working directory(Working directory is the directory where the code resides). Change the image name to reflect the name of the image to be converted. Watchout for the file extension also.

Run the program by clicking the Run button. If everything worked fine you will see a bitmap_image.h file in the current directory which contains the hex array to be used for displaying the bitmap.

img = imread(‘2.jpg’); % input image – change the file name here

s1 = fopen(‘bitmap_image.h‘,’w’); % bitmap output file – output file name


Using the created header in your code

Copy the bitmap_image.h file to the project directory and add the file to your project. Add the following line at the top of your main code.

#include “bitmap_image.h”

After that initialise the OLED display. For displaying the bitmap on to the OLED screen you can do something like this.

for (int i=0;i<128*8;i++) // show 128* 64 Logo


For correct code implementation you can download the same from our GitHub link.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s