Connecting pins of Arduino Mega with OLED Display SSD1351

I’m trying to connect the pins of my Arduino Mega with an OLED Display SSD1351.

The pins of the display are VCC, GND, SDA, SCL, CS, DC, RES, MISO, SCLK, MOSI and CS.

I connected the VCC and GND to a protoboard with 20 volts, the RES pin to the Arduino RESET pin, the MISO to the MISO, SCLK to the SCK, the MOSI to the MOSI, and the CS to the SS (I’m using SPI). I’m not so sure where I have to connect the DC pin of the display to Arduino, or if I have to use the other pins of the display.

Anyway, the display doesn’t works. And once it started smelling like it was burned :frowning: I don’t know if the damage was bad.

This is the code. The library Image.h includes images for all the numbers, because it is a tachometer.

//----------------------------------------//
//-----------1.5inch 262k OLED -----------//
//-For Arduino Mega / 328 / Gadgeteer-----//
//---------128x128 pixel SPI Mode---------//
//----------------------------------------//
//---------------www.wide.hk--------------//

#include <SPI.h>
#include “image.h”

//Arduino Mega1280 : Gadgeteer
//SDA=51 //Gadgeteer PIN7
//SCK=52 //Gadgeteer PIN9
int RES = 50; //Gadgeteer PIN4
int DC = 49; //Gadgeteer PIN5
int CS = 53; //Gadgeteer PIN6

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

//SPI Initialization
void spi_init(void)
{
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV2);//SCK frequency
SPI.setDataMode(SPI_MODE3);
}

void Write_Command(unsigned char COM)
{
digitalWrite(CS,LOW);
digitalWrite(DC,LOW);
SPI.transfer(COM);
digitalWrite(DC,HIGH);
digitalWrite(CS,HIGH);
}

void Write_Data(unsigned char DATA)
{
digitalWrite(CS,LOW);
digitalWrite(DC,HIGH);
SPI.transfer(DATA);
digitalWrite(DC,HIGH);
digitalWrite(CS,HIGH);
}

void Set_Address(unsigned char a,unsigned char b,unsigned char c,unsigned char d)
{
Write_Command(0x15);//set column address
Write_Data(a);//start address
Write_Data(b);//end address

Write_Command(0x75);//set row address
Write_Data(c);//start address
Write_Data(d);//end address
}

void SSD13xx(void)
{
Write_Command(0xfd);//set command lock
Write_Data(0x12);
Write_Command(0xfd);//set command lock
Write_Data(0xb1);
Write_Command(0xae);//display off
Write_Command(0x15);//set column address
Write_Data(0x00);
Write_Data(0x7f);
Write_Command(0x75);//set row address
Write_Data(0x00);
Write_Data(0x7f);
Write_Command(0x5c);//set write ram
Write_Command(0x5d);//set read ram
Write_Command(0xa0);//set re-map&color depth
Write_Data(0x74);
Write_Command(0xa1);//set display start line
Write_Data(0x00);
Write_Command(0xa2);//set display offset
Write_Data(0x00);
Write_Command(0xa6);//set display mode
Write_Command(0xab);//funcion selection
Write_Data(0x01);
Write_Command(0xaf);//set display on
Write_Command(0xb1);//set phase length
Write_Data(0x32);
Write_Command(0xb3); //display clock divider / oscillator frequency
Write_Data(0xf1);
Write_Command(0xb4);//set segment low voltage
Write_Data(0xa0);
Write_Data(0xb5);
Write_Data(0x55);
Write_Command(0xb5);//set gpio
Write_Data(0x0a);
Write_Command(0xb6);//set second pre-charge period
Write_Data(0x01);
Write_Command(0xb8);//gamma look up table
Write_Data(0x02);
Write_Data(0x03);
Write_Data(0x04);
Write_Data(0x05);
Write_Data(0x06);
Write_Data(0x07);
Write_Data(0x08);
Write_Data(0x09);
Write_Data(0x0a);
Write_Data(0x0b);
Write_Data(0x0c);
Write_Data(0x0d);
Write_Data(0x0e);
Write_Data(0x0f);
Write_Data(0x10);
Write_Data(0x11);
Write_Data(0x12);
Write_Data(0x13);
Write_Data(0x15);
Write_Data(0x17);
Write_Data(0x19);
Write_Data(0x1b);
Write_Data(0x1d);
Write_Data(0x1f);
Write_Data(0x21);
Write_Data(0x23);
Write_Data(0x25);
Write_Data(0x27);
Write_Data(0x2a);
Write_Data(0x2d);
Write_Data(0x30);
Write_Data(0x33);
Write_Data(0x36);
Write_Data(0x39);
Write_Data(0x3c);
Write_Data(0x3f);
Write_Data(0x42);
Write_Data(0x45);
Write_Data(0x48);
Write_Data(0x4c);
Write_Data(0x50);
Write_Data(0x54);
Write_Data(0x58);
Write_Data(0x5c);
Write_Data(0x60);
Write_Data(0x64);
Write_Data(0x68);
Write_Data(0x6c);
Write_Data(0x70);
Write_Data(0x74);
Write_Data(0x78);
Write_Data(0x7d);
Write_Data(0x82);
Write_Data(0x87);
Write_Data(0x8c);
Write_Data(0x91);
Write_Data(0x96);
Write_Data(0x9b);
Write_Data(0xa0);
Write_Data(0xa5);
Write_Data(0xaa);
Write_Data(0xaf);
Write_Data(0xb4);
Write_Command(0xbb);//set pre-charge period
Write_Data(0x17);
Write_Command(0xbe);//set vcomh voltage
Write_Data(0x05);
Write_Command(0xc1);//set contrast current
Write_Data(0xc8);
Write_Data(0x80);
Write_Data(0xc8);
Write_Command(0xc7);//set master current control
Write_Data(0x0f);
Write_Command(0xca);//set multiplex ratio
Write_Data(0x7f);
Write_Command(0xaf);//set display on
}
//Fill color
void fill(unsigned char data1,unsigned char data2)
{
unsigned int i,j;

Set_Address(0x00,0x7f,0x00,0x7f);
Write_Command(0x5C);

for(i=0;i<128;i++)
{
for(j=0;j<128;j++)
{
Write_Data(data1);
Write_Data(data2);
}
}
}

void picture1()
{
unsigned int i,j;
unsigned int x=0;

Set_Address(0x00,0x7f,0x00,0x79);
Write_Command(0x5C);

for(i=0;i<123;i++)
{
for(j=0;j<128;j++)
{
ram_val=pgm_read_byte(&(show1[x++]));// Read from Flash memoery
Write_Data(ram_val);
ram_val=pgm_read_byte(&(show1[x++]));// Read from Flash memoery
Write_Data(ram_val);
}
}
}

/* void font_show()
{
unsigned int i,j;
unsigned int x=0;

Set_Address(0x00,0x7f,0x00,0x79);
Write_Command(0x5C);

for(i=0;i<5;i++)
{
for(j=0;j<7;j++)
{
ram_val=pgm_read_byte(&(font[x++]));// Read from Flash memoery
Write_Data(ram_val);
ram_val=pgm_read_byte(&(font[x++]));// Read from Flash memoery
Write_Data(ram_val);
}
}
}
*/

void setup()
{

pinMode(RES,OUTPUT);
pinMode(DC,OUTPUT);
pinMode(CS,OUTPUT);

//SPI Initialization
spi_init();
}
void loop()
{
//RESET
digitalWrite(RES,HIGH); delay(100);
digitalWrite(RES,LOW); delay(100);
digitalWrite(RES,HIGH); delay(100);

SSD13xx();

//line(0x3c,0x6f,10,20,15,40);
fill(0xf8,0x00);
fill(0x07,0xe0);
fill(0x00,0x1f);
fill(0x22,0x00);
fill(0x07,0xff);
fill(0xff,0xe0);
fill(0xf8,0x1f);
fill(0x00,0x00);

while(1)
{
//Show Image
picture1();
Serial.print("compression ");
}
}

Thanks for your help! I would really really appreciate it.

Hi.

Put your code in code tags.
Take a look at the quote i just made.
Isn't the answer to 1 question in there ?
And did you indeed wire your display to 20 volts ?
Is it capable of handling that ?
Or required in any way ?

Code in code tags please, read the how to use the forum sticky post.

I connected the VCC and GND to a protoboard with 20 volts,

Is that the only voltage you used? The data sheet says:-

Power supply
VDD = 2.4V – 2.6V
VDDIO = 1.165V - Vcl
Vcl = 2.4 - 3.5V
Vcc = 10 - 20V

Did you do this as recommended by the data sheet:-

Power ON sequence:

  1. Power ON VCI, VDDIO.
  2. After VCI, VDDIO become stable, set wait time at least 1ms (t0) for internal VDD become stable. Then
    set RES# pin LOW (logic low) for at least 2us (t1) (4) and then HIGH (logic high).
  3. After set RES# pin LOW (logic low), wait for at least 2us (t2). Then Power ON VCC.(1)
  4. After VCC become stable, send command AFh for display ON. SEG/COM will be ON after 200ms
    (tAF).

The maximum voltage for logic signals is 3.5V did you feed 5V into it from an Arduino?

And once it started smelling like it was burned

Sounds like you killed it. Good and proper.

Grumpy_Mike:
Code in code tags please, read the how to use the forum sticky post.

I connected the VCC and GND to a protoboard with 20 volts,

Is that the only voltage you used? The data sheet says:-

Power supply
VDD = 2.4V – 2.6V
VDDIO = 1.165V - Vcl
Vcl = 2.4 - 3.5V
Vcc = 10 - 20V

Did you do this as recommended by the data sheet:-

Power ON sequence:

  1. Power ON VCI, VDDIO.
  2. After VCI, VDDIO become stable, set wait time at least 1ms (t0) for internal VDD become stable. Then
    set RES# pin LOW (logic low) for at least 2us (t1) (4) and then HIGH (logic high).
  3. After set RES# pin LOW (logic low), wait for at least 2us (t2). Then Power ON VCC.(1)
  4. After VCC become stable, send command AFh for display ON. SEG/COM will be ON after 200ms
    (tAF).

The maximum voltage for logic signals is 3.5V did you feed 5V into it from an Arduino?

And once it started smelling like it was burned

Sounds like you killed it. Good and proper.

The problem is that there are not other pins that the ones I listed... No VDD, VDDIO or Vcl

Great reply Mike !
Very comprehensive. He should have posted here before it tested it
so he could read that and avoid frying his display.
If I may ask, what possessed you to apply 20V to a display. Where did you get that particular
voltage ? Why not 18v or 16V, all of which would have fried it as well but why 20V ?

raschemmel:
Great reply Mike !
Very comprehensive. He should have posted here before it tested it
so he could read that and avoid frying his display.
If I may ask, what possessed you to apply 20V to a display. Where did you get that particular
voltage ? Why not 18v or 16V, all of which would have fried it as well but why 20V ?

You don’t have to be rude, I’m a student and I’m learning. Anyway, in Mike’s comments it says 10-20 V for VCC (the only pin it has for power supply, apart from GND), and I applied 18.

Sorry, I shouldn't have phrased it that way. I apologize for the sarcasm.
The Vcc , if I am not mistaken is for the backlight. Some take 5V, some 12Vdc, some 300Vac. Mike's
question was in reference to the logic voltage, which in this case appears to be 3.3V for Vcl.
If you applied 18V to a 20V max rated backlight you couldn't have damaged it. The question Mike
is asking is did you damage the logic circuitry by applying more than the rated 3.3 V ?

YOU SAID:-

I'm trying to connect the pins of my Arduino Mega with an OLED Display SSD1351.

now you say:-

The problem is that there are not other pins that the ones I listed... No VDD, VDDIO or Vcl

ONE of those statements is a lie.

Now if you have a display with a SSD1351 on a board then that is another matter.
You need to tell us what you actually have preferably with a link to the data sheet for it in order for you to get help from anybody.