Having trouble with the NHD-0420DZW-AB5
Hi All
I'm having quite a bit of trouble with the display mentioned in the title and getting it to work with an Arduino UNO.
I've connected the display in serial mode, and my code is as shown below. I've also redid the jumpers behind as described in the datasheet.
/*
Circuit:
CS: pin 10
MOSI: pin 11
MISO: pin 12
SCK: pin 13
*/
// the sensor communicates using SPI, so include the library:
#include <SPI.h>
const byte COMMAND = 0b11111100; // read command
const byte DATA = 0b00000010; // write command
const byte ON = 0b0000001111; //turn display on
const int chipSelectPin = 10;
void setup() {
Serial.begin(9600);
SPI.begin();
pinMode(chipSelectPin, OUTPUT);
delay(100);
digitalWrite(chipSelectPin, LOW);
delay(100);
SPI.transfer(0b0000111000);
delay(100);
SPI.transfer(0b0000001000);
delay(100);
SPI.transfer(0b0000000001);
delay(100);
SPI.transfer(0b0000000110);
delay(100);
SPI.transfer(0b0000000010);
delay(100);
SPI.transfer(0b0000001111);
digitalWrite(chipSelectPin, HIGH);
delay(100);
}
void loop() {
digitalWrite(chipSelectPin, LOW);
delay(100);
SPI.transfer(0b1000011111);
delay(1000);
digitalWrite(chipSelectPin, HIGH);
}
Most of the time, the display shows gibberish. There are occasions (1 out of 5 roughly) where the display initializes properly, and a blinking cursor is shown at the first character.
However, even when it initializes correctly, the cursor never moves, which I'm guessing means that the display isn't receiving any data from the Arduino.
This kind of baffles me because it must have received the initialization commands for it to show the blinking cursor right?
-
Just an update.
I added a line of code setting the CS pin to HIGH at the beginning, and this has gotten rid of most of the gibberish.
I still cannot, however, write anything to the screen after the initialization procedure.
Can anyone help with this please. Thanks.0 -
I have also responded to your post in the other thread about this, and I think a cause of your problem could be due to the fact that the Arduino SPI library needs 8-bit values to work properly.
0 -
Thanks for the quick reply.
I'll try using it with the Liquid Crystal library when I get the chance.0
Please sign in to leave a comment.
Comments
3 comments