Author Topic: Arduino LCD library not working with newhaven display NHD‐0420H1Z‐FL‐GWB-3V3  (Read 8801 times)

c2hollow

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
Assuming that my code for controlling the NHD‐0420H1Z‐FL‐GWB-3V3 is the reason that it isn't working, I plugged it into a breadboard and attempted to get the Arduino LCD example working:

http://arduino.cc/en/Tutorial/LiquidCrystal

However, nothing is happening. Is there anything nonstandard about the LCD controller chip in this module?

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
This display does work with the Arduino LCD library.  What voltage do you have connected to pin 3?
I just loaded this code on my Arduino Uno and connected to the display in 4-bit mode and it worked:
Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // RS connected to Arduino digital pin 12
                                        // E  connected to Arduino digital pin 11
                                        // R/W connected to Ground
                                        // DB4 connected to Arduino digital pin 5
                                        // DB5 connected to Arduino digital pin 4
                                        // DB6 connected to Arduino digital pin 3
                                        // DB7 connected to Arduino digital pin 2
void setup()
{
  lcd.begin(8, 2);                      // 8 columns, 2 rows
}

void loop()

  lcd.clear();                          //clear LCD and set cursor for upper-left corner
  lcd.setCursor(0,0);                   //set cursor for column 0, row 0
  lcd.print(" Hello");
  lcd.setCursor(0,1);                   //set cursor for column 0, row 1
  lcd.print(" World!");
  delay(1000);                          //delay for 1000ms (1 second)
  lcd.clear();
  lcd.setCursor(0,0);                   //set cursor for column 0, row 0
  lcd.print("Newhaven");
  lcd.setCursor(0,1);                   //set cursor for column 0, row 1
  lcd.print("Display");
  delay(1000);
}

c2hollow

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
Should the logic voltage supply be going into the 5V line or the 3.3V line?

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
This display is a 3.3V display so it should be powered as such, however, the Arduino Uno does not provide 3.3V logic.  I have an Arduino with a swapped voltage regulator (3.3V), but I have used 5V logic before and it still works to show something on the LCD (not recommended for extended use).  For this purpose, you may connect it to the 5.0V supply.

Have you checked what voltage you are putting on pin 3?
« Last Edit: July 08, 2014, 05:16:30 PM by Michael_L »

c2hollow

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
What happens if you run the module at 5V for too long? is there an easy way to test whether the module has gone bad?

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
I have never tested this before, but since 5V is outside the maximum rating, after many hours of use it could ruin the controller.  The only way to test if the module is functioning is to power it up and write characters to it.

c2hollow

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
I got the arduino HelloWorld example working (but only with 4 pins, not 8-pin operation). Turns out I was getting pins 1-8 mixed up with pins 7-16.

However, the sample code you provided in the other forum thread only occasionally print the correct message, and then otherwise print gibberish. The arduino helloWorld code prints gibberish in 8-bit mode.

c2hollow

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
To be specific, it only prints characters from the upper 4 bit 0110 and 0111 rows, and the lower 4 bit rows where bit 4 and bit 5 are 1.

How bizarre.

c2hollow

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
hmm I modified the original code you sent me so that it operates in 4 bit mode:
Code: [Select]
// R/W signal is tied to ground (always write, never read)

int RS = 11;   //RS signal connected to digital pin 30 of Arduino Mega2560
int E = 12;    //E signal connected to digital pin 30 of Arduino Mega2560

const char text1[] = {"Newhaven Display"};
const char text2[] = {" Character LCD  "};

void command(char c)

   digitalWrite(RS, LOW);
   PORTD = c;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
   c = c<<4;
   PORTD = c;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
}

void command8(char c)

   digitalWrite(RS, LOW);
   PORTD = c;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
}

void data(char d)
{
   digitalWrite(RS, HIGH);
   PORTD = d;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
   d= d<<4;
   PORTD = d;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
}

void Home()
{
   command(0x01);
   delay(5);
}

void nextline()
{
   command(0xC0);
}

void disp_pic()
{
   int i;
   Home();
   for (i=0;i<16;i++)
   {
      data(text1[i]);
   }
   nextline();
   for (i=0;i<16;i++)
   {
      data(text2[i]);
   }
}

void setup()
{
   DDRD = 0xFF;    //set PORTA as output
   PORTD = 0x00;   //initialize PORTA to 0x00
   pinMode(RS, OUTPUT);
   pinMode(E, OUTPUT);
   digitalWrite(E, HIGH);
   delay(40);
   command8(0x30);
   delay(5);
   command8(0x30);
   delay(5);
   command8(0x30);
   delay(5);
   command(0x28);
   command(0x10);
   command(0x0F);
   command(0x06);
   delay(5);
}

void loop()

  disp_pic();
  delay(5000);
}
and now it works perfectly fine...

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
I'm glad you got it working!  Thank you for sharing!

 

NHD-0420DZW-AG5 - Display "sometimes" shows only 2 lines

Started by stylonurusBoard OLEDs

Replies: 5
Views: 5569
Last post June 18, 2014, 10:09:49 AM
by Michael_L
NHD-C0220BiZ Sometimes Ignoring "Clear Display" Command

Started by dstoverBoard Character LCDs

Replies: 2
Views: 3739
Last post March 27, 2014, 05:41:27 PM
by Michael_L
Optical bonding Display to cover glass (dry film bonding)

Started by fourtraxBoard TFTs

Replies: 1
Views: 1095
Last post September 29, 2016, 08:35:00 AM
by Saurabh_B
Display current of 128x64 yellow OLED (2.7-12864UMY3) really 175mA?

Started by flywheelBoard OLEDs

Replies: 1
Views: 3386
Last post June 30, 2014, 04:48:12 PM
by Michael_L
Wiring between NHD-1.5128128ASC3ND OLED Display and NHDev 2.10 Development Board

Started by vcp88Board OLEDs

Replies: 2
Views: 2069
Last post November 19, 2017, 09:59:31 PM
by tolikkk