Problem with NHD-C0220BiZ LCD
Hi All,
I've a problem with the initialization of the NHD-C0220BiZ LCD. The code that i use is the same used with NHD-C00216CIZ, this one worked but changing the I2C address and the LCD with the first one not work. The LCD seems to be initialized, i see the black squares in background but when I stop the I2C connection the LCD seems to restart itself.
Where is the issu, please help.
-
The same code works between the two displays, if the slave address is changed. Do you have the same setup as you did with the C0216CiZ? I have provided some Arduino code for this display below, (you will see that it says C0216CiZ, but you will see in the comments by the slave address how it should be changed):
#include <Wire.h>
int RES = 22;
int ASDA = 20;
int ASCL = 21;
int test = 55;
unsigned char text1[]={"Newhaven Display"};
unsigned char text2[]={" I2C TEST "};
unsigned char text3[]={" March 26 2014 "};
unsigned char text4[]={" Michael LaVine "};
const char slave2w = 0x3C; //3E for CiZ (0x7C shifted over 1 bit) //3C for BiZ (0x78 shifted over 1 bit)
const char comsend = 0x00;
const char datasend = 0x40;
const char line2 = 0xC0;
void show(unsigned char *text)
{
int n, d;
d=0x00;
Wire.beginTransmission(slave2w);
Wire.write(datasend);
for(n=0;n<16;n++)
{
Wire.write(*text);
++text;
}
Wire.endTransmission();
}
void nextline(void)
{
Wire.beginTransmission(slave2w);
Wire.write(comsend);
Wire.write(line2);
Wire.endTransmission();
}
void CGRAM(void)
{
Wire.beginTransmission(slave2w);
Wire.write(comsend);
Wire.write(0x38);
Wire.write(0x40);
Wire.endTransmission();
delay(10);
Wire.beginTransmission(slave2w);
Wire.write(datasend);
Wire.write(0x00);
Wire.write(0x1E);
Wire.write(0x18);
Wire.write(0x14);
Wire.write(0x12);
Wire.write(0x01);
Wire.write(0x00);
Wire.write(0x00);
Wire.endTransmission();
}
void CiZ_init()
{
Wire.beginTransmission(slave2w);
Wire.write(comsend);
Wire.write(0x38);
delay(10);
Wire.write(0x39);
delay(10);
Wire.write(0x14);
Wire.write(0x70);
Wire.write(0x5E);
Wire.write(0x6D);
Wire.write(0x0C);
Wire.write(0x01);
Wire.write(0x06);
Wire.endTransmission();
CGRAM();
Wire.beginTransmission(slave2w);
Wire.write(comsend);
Wire.write(0x39);
Wire.write(0x01);
test = Wire.endTransmission();
Wire.endTransmission();
if(test!=0)
{
while(1)
{
delay(100);
}
}
delay(10);
}
void setup()
{
pinMode(RES, OUTPUT);
pinMode(ASCL, OUTPUT);
pinMode(ASDA, OUTPUT);
digitalWrite(RES, HIGH);
delay(10);
digitalWrite(ASCL, LOW);
digitalWrite(ASDA, LOW);
delay(10);
delay(10);
//CiZ_init();
//delay(5);
}
void loop()
{
Wire.begin();
//TWBR = 12;
//TWSR |= _BV(TWPS0);
while(1)
{
CiZ_init();
show(text1);
nextline();
show(text2);
delay(1000);
CiZ_init();
show(text3);
nextline();
show(text4);
delay(1000);
}
}0 -
Thank you!, I've solved the problem.
Now I've another question: is it possible to add custom characters?0 -
Yes you can add custom characters to the CGRAM of the ST7036. In the ST7036 datasheet, see pages 22-23 for details on the CGRAM, and pages 27 & 33 for details on how to use this command. I've provided a small example below of me making a smiley face to address location 0x00 of the CGRAM:
void i2cwritecom(unsigned char c)
{
Wire.beginTransmission(slave2w); //slave2w = 0x3C (0x78 shifted over 1 bit)
Wire.write(comsend); //comsend = 0x00
Wire.write(c);
Wire.endTransmission();
}
void i2cwritedat(unsigned char d)
{
Wire.beginTransmission(slave2w);
Wire.write(datasend); //datasend = 0x40
Wire.write(d);
Wire.endTransmission();
}
void CiZ_init()
{
Wire.beginTransmission(slave2w);
Wire.write(comsend);
Wire.write(0x39);
delay(1);
Wire.write(0x14);
Wire.write(0x70);
Wire.write(0x5E);
Wire.write(0x6D);
Wire.write(0x0C);
Wire.write(0x01);
Wire.write(0x06);
Wire.endTransmission();
}
void setup()
{
pinMode(RES, OUTPUT);
pinMode(ASCL, OUTPUT);
pinMode(ASDA, OUTPUT);
digitalWrite(RES, HIGH);
delay(10);
digitalWrite(ASCL, LOW);
digitalWrite(ASDA, LOW);
delay(10);
Wire.begin();
delay(10);
CiZ_init();
delay(5);
i2cwritecom(0x38); //function set to set IS[2:1] to 0,0
i2cwritecom(0x40); //set CGRAM address (in this case, to 0x00)
i2cwritedat(0x1B); //write custom pattern to CGRAM
i2cwritedat(0x00); //
i2cwritedat(0x0A); //
i2cwritedat(0x0A); //
i2cwritedat(0x00); //
i2cwritedat(0x04); //
i2cwritedat(0x11); //
i2cwritedat(0x0E); //
i2cwritecom(0x01); //clear display and set DDRAM address to 0x00 (line 1, character 1)
delay(2); //2 ms delay
i2cwritedat(0x00); //write custom pattern stored in CGRAM address location 0x00 to DDRAM
}0 -
Thank you!
0
Please sign in to leave a comment.
Comments
4 comments