Newhaven Products > Character LCDs

NHD-0420D3Z-FL-GBW-V3 not displaying cahracters

(1/1)

T3Mentor:
I am using a NHD-0420D3Z-FL-GBW-V3 in the SPI mode to interface to an Arduino Uno.  Every time I write to the display, all the pixels in a character are illuminated,  as if is sent FF, rather than the actual 31 (1) that I was using to test my set up.  I have the baud rate set at 9600 (yes, slow I know, but I'm just testing at this point ) , MSBFIRST, and SPIMODE3.   I'm not sure what's going on here, any advice?   

Saurabh_B:
Hello,

I have attached my SPI Code for this display using an Arduino:

--- Code: ---//---------------------------------------------------------
/*
SPI Code.c
Program for writing to Newhaven Display Serial LCD Character Displays via SPI.

(c)2016 Saurabh Baxi - Newhaven Display International, LLC.

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
*/
//---------------------------------------------------------


// DEFINITIONS
#define SCLK  8
#define  SPIS  9
#define SDO   10

const char slave = 0x7E;
const char comsend = 0x00;
const char datasend = 0x40;

char const t1[]=(" Newhaven  Display  ");
char const t2[]=("=SERIAL==Peripheral=");
char const t3[]=("=====Interface======");
char const t4[]=("=ARDUINO=====TESTER=");
//Basic Functions/////////////////////////////
void spiout(unsigned char a){
  int n;
  unsigned char d;
  d = a;
  digitalWrite(SPIS,LOW);
  for(n =0; n<8; n++){
    delayMicroseconds(20);
    if((d&0x80)==0x80)
      digitalWrite(SDO, HIGH);
    else
      digitalWrite(SDO, LOW);
    d = (d<<1);
    digitalWrite(SCLK, LOW);
    delayMicroseconds(20);
    digitalWrite(SCLK, HIGH);
  }
  digitalWrite(SPIS, HIGH);
}
void disp(const char *text){
  int n;
  for (n = 0; n <20 ; n++){
    spiout(*text);
    text++;
    delay(10);
  }
}

void setup() {
  pinMode(SPIS, OUTPUT);
  pinMode(SDO, OUTPUT);
  pinMode(SCLK, OUTPUT);
  digitalWrite(SCLK, LOW);
  digitalWrite(SDO, LOW);
  digitalWrite(SPIS, HIGH);
  delay(10);
  spiout(0xFE);
  spiout(0x51); //Clear Screen
  delay(10);
  spiout(0xFE);
  spiout(0x46); //Cursor Home
  delay(5);
  spiout(0xFE);
  spiout(0x47); // Underline cursor
  delay(5);
  spiout(0xFE);
  spiout(0x53); // Set backlight Brightness
  spiout(8); // Value
  delay(2);
  spiout(0xFE);
  spiout(0x52); // Set Contrast
  spiout(40); // Value
}

void loop() {
  int i;
  spiout(0xFE);
  spiout(0x46); // Cursor Home
  delay(10);
  disp(t1); // Display T1
  delay(5);
  spiout(0xFE);
  spiout(0x45); // Set Curser Address
  spiout(0x40); // Line 2
  delay(5);
  disp(t2);
  spiout(0xFE);
  spiout(0x45);
  spiout(0x14); // Line 3
  delay(5);
  disp(t3);
  spiout(0xFE);
  spiout(0x45);
  spiout(0x54); // Line 4
  delay(5);
  disp(t4);
  spiout(0xFE);
  spiout(0x49); // Move cursor left 1 place
 while(1); // Wait here
}

--- End code ---

Would you be able to send a picture of what you are seeing?

Navigation

[0] Message Index

Go to full version