NHD-0420DZ-NSW-BBW don't display any character
I have a NHD-0420DZ-NSW-BBW connected to an arduino to test it. I am using 4bit connection. Wirings are:
D0 = 0; // B4
D1 = 0; // B5
D2 = 0; // B6
D3 = 0; // B7
D5 = 0; // pin E
D6 = 0; // pin R/W low=w, high=read
D7 = 0; // RS low=instruction, high=data
D9=0; // Contrast
I have used the sample code from newhaven site:
https://www.newhavendisplay.com/resources_dataFiles/excode/txt/CharLCD/4bit_character.txt
And this is the 'translated' code for arduino uno:
/*
D0 = 0; // B4
D1 = 0; // B5
D2 = 0; // B6
D3 = 0; // B7
D5 = 0; // pin E
D6 = 0; // pin R/W low=w, high=read
D7 = 0; // RS low=instruction, high=data
D9=0; // Contrasto
*/
int _EN = 5;
int _RW = 6;
int _RS = 7;
int _contrast = 9;
int _B4 = 0;
int _B5 = 1;
int _B6 = 2;
int _B7 = 3;
void setup() {
// put your setup code here, to run once:
pinMode(_B4, OUTPUT);
pinMode(_B5, OUTPUT);
pinMode(_B6, OUTPUT);
pinMode(_B7, OUTPUT);
pinMode(_EN, OUTPUT); // pin E
pinMode(_RW, OUTPUT); // pin R/W low=w, high=r
pinMode(_RS, OUTPUT); // pin RS
Serial.begin(9600);
start();
Serial.println("clear display and home");
command(0x01);
Serial.println("Writing Hello");
Write('H'); Write('e'); Write('l'); Write('l'); Write('o');
analogWrite(_contrast, 127); // set contrast to half course
}
void loop() {
//Serial.println("ingresso loop");
delay(100);
}
void WriteData(char i) {
digitalWrite(_B4, ((i & 0x10) != 0) ? HIGH : LOW);
digitalWrite(_B5, ((i & 0x20) != 0) ? HIGH : LOW);
digitalWrite(_B6, ((i & 0x40) != 0) ? HIGH : LOW);
digitalWrite(_B7, ((i & 0x80) != 0) ? HIGH : LOW);
}
/**********************************************************/
void command(char i)
{
WriteData(i); //put data on output Port
digitalWrite(_RS, LOW); //D_I = 0; //D/I=LOW : send instruction
digitalWrite(_RW, LOW); //R_W = 0; //R/W=LOW : Write
Nybble(); //Send upper 4 bits
i = i << 4; //Shift over by 4 bits
WriteData(i);
Nybble(); //Send upper 4 bits
}
/**********************************************************/
void Write(char i)
{
WriteData(i); //put data on output Port
digitalWrite(_RS, HIGH); //D_I = 1; //D/I=HIGH : send data
digitalWrite(_RW, LOW); //R_W = 0; //R/W=LOW : Write
Nybble(); //Clock upper 4 bits
i = i << 4; //Shift over by 4 bits
WriteData(i); //put data on output Port
Nybble(); //Clock upper 4 bits
}
/**********************************************************/
void Nybble()
{
digitalWrite(_EN, HIGH); // E = 1;
delay(10); //enable pulse width >= 300ns
digitalWrite(_EN, LOW); // E = 0; Clock enable: falling edge
delay(10); //enable pulse width >= 300ns
}
/**********************************************************/
void start()
{
WriteData(0);
Serial.println("Inizializzazione...");
digitalWrite(_RS, LOW); //D_I = 0; //D/I=LOW : send instruction
digitalWrite(_RW, LOW); //R_W = 0; //R/W=LOW : Write
digitalWrite(_EN, LOW);
Serial.println("watinig 1 sec");
delay(1000); //Wait >40 msec after power is applied
WriteData(0x30); //put 0x30 on the output port
delay(30); //must wait 5ms, busy flag not available
Nybble(); //command 0x30 = Wake up
delay(10); //must wait 160us, busy flag not available
Nybble(); //command 0x30 = Wake up #2
delay(10); //must wait 160us, busy flag not available
Nybble(); //command 0x30 = Wake up #3
delay(10); //can check busy flag now instead of delay
WriteData(0x20); //put 0x20 on the output port
Nybble(); //Function set: 4-bit interface
Serial.println("functionset 4bit/4linee");
command(0x28); //Function set: 4-bit/4-line
Serial.println("display on and blinking cursor");
command(0x08); //Display ON; Blinking cursor
Serial.println("cursor shift");
command(0x14); //Set cursor
Serial.println("entry mode set");
command(0x06); //Entry Mode set
}
The display simply doesn't show anything... i can only see the 4x20 character blocks that changes intensity if i changes the contrast in the setup function.
With an oscilloscope is see a strange thing... on pin B4 and B5, i have 5v also when arduino pull it down to 0v... i have double checked the wiring and i have no short circuit.
p.s.: i have a second display unit and the behaviour is the same, also the strange 5v on B4 and B5.
With an oscilloscope is see a strange thing... on pin B4 and B5, i have 5v also when arduino pull it down to 0v... i have double checked the wiring and i have no short circuit.
p.s.: i have a second display unit and the behaviour is the same, also the strange 5v on B4 and B5.
0
-
Hi Sioux1977,
Please confirm the 4-bit mode is writing to the high order bits DB4 - DB7 on the display pins 11 to 14.
The low order bits DB0 - DB3 on pins 7 to 10 should not be connected.
Regards,0
Please sign in to leave a comment.
Comments
1 comment