Introduction: How to Use OLED Display Arduino Module

Hello guys, this is the first time we(smart prototyping) post an instructable here, thanks for watching! We will keep on post funny instructable, hope we can help you a little and communicate with your guys!

Here is the 0.96 inch OLED display instructables for how to display chars and binary BMP picture.
This 0.96inch OLED display has 128x64 resolution, three kind of light color, blue light white light and blue/yellow light, I think the blue light has better display effect than the others. The display with small dimension, very suitable for smart watch, function cellphone, smart health device, now let's start using it to display chars and a Bentley logo picture.

No need to understand any code here, just following the step to do it, you will know how it work and you can control it whatever you like to display.

Here is our product page:

OLED 0.96inch 12864 display module

Dupont Wire Male to Male 40P 2.54mm 20cm

Step 1: ​Connecting the Module to Arduio, This OLED Module Have Six Pins,

Connecting the module to Arduio, this OLED module have six pins,
OLED-------Arduino

D0-----------10

D1-----------9

RST----------13

DC-----------11

VCC----------5V

GND----------GND

Step 2: Copy the Code in Arduino IDE, and Change the Chars in Function "LED_P8x16Str"

down load this Arduino code, and copy it to Arduino IDE.

Find below code in the bottom,

void loop()
{

LED_P8x16Str(23,0,"welcome to");

LED_P8x16Str(40,2,"Smart");

LED_P8x16Str(20,4,"Prototyping");

}

Here you can change the comment that you want to display in line 1, line two, line three. The first and second parameter is the starting x,y coordinate.

Step 3: Upload the Code

Upload the code, then you will see the text showing on display now!

Step 4: Now Start to Display a Bentley Logo

Here is the bentley logo picture here, transfer the picture to 128x64 pixel, save the picture.

if you don't know how to transfer the picture pixel, please download the 128x64 bmp here

Step 5: Transfer the Pic to Binary Code

Use the following soft transfer the BMP code to binary code,

Download bitmap_converter

save output to "logo.txt", open the logo.txt you will see the picture's binery code in
const unsigned char logo [] = {

...

};

Step 6: Copy the Binary Code in to Arduino IDE

Copy this example code(code-bmp.txt) to Arduino IDE

Instead the picture binary code in example code.

find the "

const unsigned char logo[]

"

and copy the code to this funtion. if you don't understand this step, you can just run the example code...

Step 7: Upload Code Done!

Now you can see it display on the OLED!

Comments

author
Akshayk186 made it! (author)2017-07-16

I used 12864 SPI Blue OLED Display Module with 6 pins ( Default hardware configuration is set to 4 pin SPI ).

In the display two ports are marked wrongly as

Data_in as SDA = D1

CLK as SCL = D0

CLK is our D0 port

Din is our D1 port

here are the connections :

Display Pin Arduino Pin

1 GND GND

2 VCC VCC 3.3V

3 SCL(CLK) D0 10

4. SDA(DATA_in) D1 9

5 RES 13

6. DC 11

Here a

IMG_0018.JPGIMG_0019.JPGIMG_0016.JPGIMG_0015.JPGIMG_0016.JPG
author
yashverma28091995 made it! (author)2017-06-22

Thanks

WhatsApp Image 2017-06-23 at 11.17.15.jpeg
author
STom68 made it! (author)2017-06-03

Great, thank you!

20170603_182123.jpg
author
RomainM14 (author)2017-04-19

Hi is it possible to change the size of the text and the color even if I think I have a monochrome I could always thank thank you very much of your work is the only code that works for me

author
ibenkos (author)2014-10-23

Very smart idea! Good jub :)

author
Alex_chu (author)ibenkos2014-12-02

yeah,Thanks,you can find more useful moudle in Smart-prototyping.

author
Aimeiz made it! (author)Alex_chu2016-01-31

Hello.

I have "universal" module which could be used as 4SPI (ssems to be set to this mode), 3SPI and I2C. (See images).

On back side of the module is written which resistor should be solderd for each mode. Now I see R3 and R4 but not R2 and R8 - seems 4SPI

R2 R3 means 3SPI

R1, R4, R6, R7, R8 is marked as IIC.

I would like to chcnge it to IIC,

So i think that I have to unsolder R3 and R5 and solder them to R1 and R8 respectively \Am I right?

Then I will have problem with signal identification.

Module has 7 pins:

GND, VCC - which is clear

D0, D1, RES, DC, CS.

I2C modules have only 4 pins VCC, GND, SCL, SDA

So which pins from my display after modification will be SCL and which SDA?

This module is quite popular so i belive that somebody played with this modification.

Please advice.

oled back.JPGoled front.JPG
author
gepd (author)Aimeiz2017-03-28

I have found this datasheet with the especification of the Interface selection: http://www.rhydolabz.com/documents/SSD1306.pdf (Page 16 Point 8.1)

author

i've tried it but couldn't be successful. It works only in SPI mode :(

author
drchance (author)2016-02-15

hmmm ... great code ... it seemed to verify/compile without warnings or errors. However ... on my display, which looks identical to the one in your images, the bitmap image looks like it has some "moving artifacts" ... it's probably better explained with a video (below). The text just says "TEST" bit it looks like it's trying to scroll or something. I've reduced the bitmap to a single letter and it still has that movement in the bitmap image ... weird ... I'll continue to test but I was hoping someone else may have some idea as to what is happening here. Thanks for any input.

http://www.screencast.com/t/PJUWSvSfQ

author
TeamZ1 (author)drchance2016-08-04

If your oled has a 'cs' port try to ground it and reset the arduino

author
o_gardiner (author)TeamZ12017-02-12

Great tip, thanks, now the display is working. Could you explain (or refer to an explanation of) what the CS pin does and why it has to be connected to ground? Thanks!

author
SPLatManOz (author)o_gardiner2017-02-13

I had the same problem, and fixed it by grounding CS.

CS means "chip select". It is a line used to select or activate one chip/module out of maybe several. In this module it should really be named CS- or CS*, meaning it is asserted when /low/.

If it is left open its state will be indeterminate, and very likely alternating between low and hi as it is affected by ambient electrical fields. Connecting it to ground makes the display permanently selected and respond properly to everything else.

author
o_gardiner (author)SPLatManOz2017-02-14

Thank you, that's a really helpful explanation! It's always nice to know *why* something is working instead of some 'magic' that I can't explain...

author
jackb161 (author)drchance2016-07-22

try to put

delay(100);

at the end of the loop

author
roberto.petresco.1 (author)2017-02-02

Hi, first of all thank you for the tutorial.

I have a 6 pin 0.96 inch oled. I used SCL with D10 and SDA with D9

After compiling I saw the deprecated string conversion warnings and a

low memory available stability problems may occur.

However nothing appeared on oled it looked totally off.

Any hints of what may be wrong

author
adrianmvd made it! (author)2016-11-24

great tutorial! thank you very much

temp_1627308256.jpg
author
SaeedV3 (author)adrianmvd2016-12-11

Hi,

How you change the color? in above code I cant find any section or function for set color.

author
adrianmvd (author)SaeedV32017-01-26

Hi SaeedV3,

it's just the first line that is always yellow. you can't change the color, just move the text to the yellow upper area or down in the white area. Is still a monochromatic display

Regards

author
Amartya737 (author)SaeedV32017-01-03

You have non color version of the LCD

author
Vickey98 (author)2017-01-02

dear i done it but

i want to send the text by android app via bluetooth pls can u help me how to send text by bluetooth

author
Shahid Khattak (author)2016-12-31

My OLED have six pins

GND

VCC

CLK

MOSI

DC

CS

How to connect?

author
ShreejaD (author)2016-07-26

I AM CONSTANTLY GETTING THIS ERROR:

exit status 1

invalid conversion from 'const char*' to 'unsigned char*' [-fpermissive]

author
link5505 (author)2016-07-07

Hi, how could I learn to make a voltage meter up to 50.4v? Thanks!

author
kolitham (author)2016-06-09

Hi,

Cannot download the code. Please help.

author
Alex_chu (author)kolitham2016-07-04

Hi Kolitham, sorry for the truoble, I just update the code link, you can download it now.

Best, Alex Chu

author
kolitham (author)Alex_chu2016-07-04

Thanks Alex

author
Arduino Tech (author)2015-03-17

Mine has 8 pins :
Vcc
Gnd
NC
Din
CLK
CS
D/C
RES

What should I do ??

author
Alex_chu (author)Arduino Tech2015-04-09

CLK is our D0 port,

Din is our D1 port,

ignore your NC and CS port, try it again, if not worked you can try to plug CS to GND or VCC, good luck!

author
SrabonH1 (author)Alex_chu2015-11-07

For 8 pins. It worked Perfectly. Connect CS to GND.

author
NikolaKoren (author)SrabonH12016-06-09

thenks. very importent information.

author
Trevor0812 made it! (author)2016-02-19

Hi,

My OLED has 16 pins as it is able to use different modes. What pins would I use?

OLED 16 Pin.PNG
author
Taufikt (author)2016-02-09

nice...........

author
Taufikt (author)2016-02-09

nice...........

author
MothyaM (author)2016-02-07

hi to all,

i am mothiram, using NHD-2.7-128X64UCY3 OLED Display with SPI interface.

here am facing one problem while writing byte data to display through write_data, can any one help me out with related example.

thanks.

author
Jim Flower (author)2016-02-05

Hi Alex I have just received my very first Arduino Duo together with this very display. I'm new to Arduino's and am trying to learn the programming. I have experimented with Blink and using a potentiometer to read values serially all worked great.

This is going to be a total newbie question but I just down loaded the code and tried to make a new sketch then verify it but is keeps coming back with so many errors I'm not sure I'm doing it correctly. Can you you please walk a total newbie through the sequence correctly?

author
MarkyD2 (author)2015-11-17

Hi I got it working and removed the line

can you tell me how to set a delay and then print something else like a valeu from a sensor?

author
printrbot932 (author)2015-05-08

I changed mine to hello world but it still has a line on one side ? Help please

15, 9:00 AM.jpg
author
JDGE (author)printrbot9322015-11-03

I know this is old but I had the same problem with my display.Try changing the bold numbers below from 128 to 130. This fixed my problem.

void LED_Fill(unsigned char bmp_data)
{
unsigned char y,x;

for(y=0;y<8;y++)
{
LED_WrCmd(0xb0+y);
LED_WrCmd(0x00);
LED_WrCmd(0x10);
for(x=0;x<128;x++)
LED_WrDat(bmp_data);
}
}



void LED_CLS(void)
{
unsigned char y,x;
for(y=0;y<8;y++)
{
LED_WrCmd(0xb0+y);
LED_WrCmd(0x00);
LED_WrCmd(0x10);
for(x=0;x<128;x++)
LED_WrDat(0);
}
}

author
Dushan PasinduT (author)2015-11-03

my display has only 4 pins

VCC

GND

SCL

SDA

author
wanikmal (author)2015-10-24

Hello Alex, firstly i would like to thank you for all the informations and steps provided and really appreciated it. I would like to used the OLED display vertically and could you give me sample of coding to display vertically.

author
rammrg (author)2015-09-27

Dear frinds i want to programming of rtc interfacing with 8051 my mail id is rammrg007@gmail.com mobile no. 9042816495

author
rammrg (author)2015-09-27

Dear frinds i want to programming of rtc interfacing with 8051 my mail id is rammrg007@gmail.com mobile no. 9042816495

author
rammrg (author)2015-09-27

Dear frinds i want to progarmming of oled interface with arduino

author
GiorgioF1 (author)2015-09-13

Hello Dear, it is possible write The text by 90 degree rotated? I Just want to use The lcd in vertical position...

author
rammrg (author)GiorgioF12015-09-27

Hollw sir i want programme for interface oled with arduino my mail id is rammrg007@gmail.com

author
TheodoreF1 (author)2015-09-07

Beware of OLED burn in. If you leave a bitmapped image on for several hours, the phosphors will leave a ghost image. I now get to see Mr. Bentley 24-7. hehe

https://www.instructables.com/id/Temp-Humid-and-Tim...

author
PhamA1 (author)2015-08-04

hello :) thanks for your AWESOME instructable but can you help me with this one ? i have 1 oled display but i have no idea how to connect it to my adruino nano here are the pins on my dispay
vcc
gnd
clk
mosi
cs
d/c

author
Alex_chu (author)PhamA12015-08-04

CLK--------D10

MOSI------D9

D/C---------D11

VCC--------3.3v

GND--------GND

Ignore CS first, If not work,try to connect CS to GND or 3.3V

author
DolboD (author)Alex_chu2015-08-25

Hmm, are you describing the SPI mode? But the code in you link seems to use I2C?

Here:

int SCL_PIN=10;//D0
int SDA_PIN=9; //D1

Plus, I am confused since according to the SSD1306 spec, they use some weird wiring for the I2C mode, two SDA?! This is really confusing.

Also, the code you attached doesn't seem to be using either hardware SPI or hardware I2C. Some sort of bitbanging? So which is it? SPI or I2C or really neither?