OLED 128x64 Grove Display

Hi

I connected my Grove oled 128x64 to the I2C-1 port in Grove - Base Shield and it don’t work with the following code. Is my connection problem or Oled hardware problem ?

#include <Wire.h>
#include <data.h>
#define OLED_address 0x3c

unsigned char fill_OLED=0x55;
unsigned char fill_string1[]=“SeeedStudio”;
unsigned char fill_string2[]=“OLED 128*64”;
unsigned char fill_string3[]=“0123456789ABCDEF”;
unsigned char fill_string4[]=“SS”;
extern unsigned char myFont[][8]; //PROGMEM
extern unsigned char logo[];
extern unsigned char ip[];

//==================================
void print_a_char(unsigned char ascii=0)
{
unsigned char i=0;
for(i=0;i<8;i++)
{
SendChar(myFont[ascii-0x20][i]);
}
}

//==================================
void setup()
{

Wire.begin();
init_OLED();
delay(10);
clear_display();
delay(50);
}

//========================
void loop()
{
clear_display();
delay(50);

sendcommand(0x20); //Set Memory Addressing Mode
sendcommand(0x02); //Set Memory Addressing Mode ab Page addressing mode(RESET)

sendcommand(0xa6); //Set Normal Display (default)
setXY(3,3);
sendStr(fill_string1);
setXY(4,3);
sendStr(fill_string2);

delay(2000);
sendcommand(0xa7); //Set Inverse Display
delay(2000);

clear_display();
delay(50);

sendcommand(0xa6); //Set Normal Display

sendcommand(0xae); //display off
sendcommand(0x20); //Set Memory Addressing Mode
sendcommand(0x00); //Set Memory Addressing Mode ab Horizontal addressing mode

for(int i=0;i<1288;i++)// write a 128 64 picture
{
SendChar(logo[i]);
// delay(1);
}

sendcommand(0xaf);
delay(2000);
sendcommand(0xa7); //Set Inverse Display
delay(2000);

while(1)
{
// sendcommand(0xa6); Set Normal Display
sendcommand(0x29); //Vertical and Horizontal Scroll Setup
sendcommand(0x00); //dummy byte
sendcommand(0x00); //define page0 as startpage address
sendcommand(0x00); //set time interval between each scroll ste as 6 frames
sendcommand(0x07); //define page7 as endpage address
sendcommand(0x01); //set vertical scrolling offset as 1 row
sendcommand(0x2f); //active scrolling
delay(3000);

};

}

//=======================
void sendcommand(unsigned char com)
{
Wire.beginTransmission(OLED_address); //begin transmitting
Wire.write(0x80);//command mode
Wire.write(com);
Wire.endTransmission(); // stop transmitting
}

//==================================
void clear_display(void)
{
unsigned char i,k;
for(k=0;k<8;k++)
{
setXY(k,0);
{
for(i=0;i<128;i++)//clear all COL
{
SendChar(0);
//delay(10);
}
}
}
}

//===================================
void SendChar(unsigned char data)
{
Wire.beginTransmission(OLED_address); // begin transmitting
Wire.write(0x40);//data mode
Wire.write(data);
Wire.endTransmission(); // stop transmitting
}

//===================================
void setXY(unsigned char row,unsigned char col)
{
sendcommand(0xb0+row); //set page address
sendcommand(0x00+(8col&0x0f)); //set low col address
sendcommand(0x10+((8
col>>4)&0x0f)); //set high col address
}

//==================================
void sendStr(unsigned char *string)
{
unsigned char i=0;
//setXY(0,0);
while(*string)
{
for(i=0;i<8;i++)
{
SendChar(myFont[*string-0x20][i]);

//SendChar(*string);
delay(10);
}
*string++;
}
}
//=================================
void init_OLED(void)
{

sendcommand(0xae); //display off
delay(50);
// sendcommand(0xa0); //seg re-map 0->127(default)
// sendcommand(0xa1); //seg re-map 127->0
// sendcommand(0xc8);
// delay(1000);
sendcommand(0xaf); //display on

delay(50);

}

Hi , :slight_smile:
It that demo code ? If it can not compiled , you can try to use arduino-0022 .

Deray

Hi , :slight_smile:
It that demo code ? If it can not compiled , you can try to use arduino-0022 .

Deray

Thanks.

I found out why my OLED 128x64 Grove Display didn’t work.

It seems that it is not compatible with my GPRS Shield

and I need to use another demo code.

#include <Wire.h>
#include <SeeedOLED.h>

void setup()
{
Wire.begin();
SeeedOled.init(); //initialze SEEED OLED display
DDRB|=0x21; //digital pin 8, LED glow indicates Film properly Connected .
PORTB |= 0x21;

SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
SeeedOled.setNormalDisplay(); //Set display to Normal mode
SeeedOled.setPageMode(); //Set addressing mode to Page Mode
SeeedOled.setTextXY(0,0); //Set the cursor to 0th Page, 0th Column
SeeedOled.putNumber(123); //Print number
SeeedOled.setTextXY(1,0); //Set the cursor to 1st Page, 0th Column
SeeedOled.putNumber(0xFFFF); //Print number
SeeedOled.setTextXY(2,0); //Set the cursor to 2nd Page, 0th Column
SeeedOled.putNumber(0xFFFFFFFF); //Print number
SeeedOled.setTextXY(3,0); //Set the cursor to 3rd Page, 0th Column
SeeedOled.putNumber(-12345); //Print number

}

void loop()
{

}