Author Topic: NHD‐0420DZW‐AB5 Lines  (Read 2273 times)

RickJ

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
NHD‐0420DZW‐AB5 Lines
« on: January 08, 2015, 09:45:54 PM »
I have this display working except for lines 2 & 4. The address counter seems to be correct.
0x40 for Line 2 and 0x54 for Line 4 are returned when checking busy flag but nothing displays. Line 1 and 3 work correctly.
Maybe I'm missing something????

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD‐0420DZW‐AB5 Lines
« Reply #1 on: January 09, 2015, 04:18:32 PM »
It seems like you may not be addressing the lines correctly?  Take a look at the code below:

Code: [Select]
//---------------------------------------------------------
/*
NHD_0420DZW_mega.ino
Program for writing to Newhaven Display 4 x 20 Character OLED (4-bit, 6800 mode)

(c)2014 Mike LaVine - 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.
*/
//---------------------------------------------------------

// The 4 bit data bus is connected to PORTA[3..0] of the Arduino Mega2560

int RS =  30;    // RS signal connected to digital pin 30 of Arduino Mega2560
int RW =  31;    // R/W signal connected to digital pin 31 of Arduino Mega2560
int  E =  32;    // E signal connected to digital pin 32 of Arduino Mega2560

const char text1[] = {"  Newhaven Display  "};
const char text2[] = {"   Character OLED   "};
const char text3[] = {"  4 Line x 20 Char  "};
const char text4[] = {"0123456789!@#$%^&*()"};

void toggle()
{
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
}

void command(char c)

   
   PORTA = (c>>4);
   digitalWrite(RS, LOW);
   toggle();
   //delay(10);
   PORTA = c;
   toggle();
}

void data(char d)
{
   
   PORTA = (d>>4);
   digitalWrite(RS, HIGH);
   toggle();
   //delay(10);
   PORTA = d;
   toggle();
}



void disp()
{
   int i;
   delay(50);
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   delay(5);
   for (i=0;i<20;i++)
   {
      data(text1[i]);
   }
   command(0xC0);  //Second Line  [Set DDRAM address to Line 2 position 1]
   for (i=0;i<20;i++)
   {
      data(text2[i]);
   }
   command(0x94);  //Third Line  [Set DDRAM address to Line 3 position 1]
   for (i=0;i<20;i++)
   {
      data(text3[i]);
   }
   command(0xD4);  //Fourth Line  [Set DDRAM address to Line 4 position 1]
   for (i=0;i<20;i++)
   {
      data(text4[i]);
   }
}

void setup()
{
   //delay(200);
   
   DDRA = 0xFF;    //set PORTA (dat bus) as output
   PORTA = 0x00;   //initialize PORTA to 0x00
   DDRC = 0xFF;    //set PORTC (control lines) as output
   PORTC = 0x00;   //initialize PORTC to 0x00
   delay(5);
   toggle();
   delay(5);
   //toggle();
   //delay(5);
   //toggle();
   //delay(5);
   
   
   PORTA = 0x2;
   toggle();
   command(0x28);
   //command(0x28);
   //toggle();
   //PORTA = 0x8;
   //toggle();
   /*PORTA = 0x2;
   toggle();
   toggle();
   PORTA = 0x8;
   toggle();*/
   /*PORTA = 0x2;
   toggle();
   toggle();
   PORTA = 0x8;
   toggle();*/
   PORTA = 0x0;
   toggle();
   PORTA = 0x8;
   toggle();
   PORTA = 0x0;
   toggle();
   PORTA = 0x1;
   toggle();
   delay(5);
   PORTA = 0x0;
   toggle();
   PORTA = 0x6;
   toggle();
   PORTA = 0x0;
   toggle();
   PORTA = 0x2;
   toggle();
   PORTA = 0x0;
   toggle();
   PORTA = 0xC;
   toggle();
   delay(10);
}

void loop()

  disp();
  delay(3000);
}

Take special note of the disp() function, as it addresses each line and writes to it successfully.

 

NHD-0420DZW-AG5 OLED character module--Displaying junk data

Started by control3Board OLEDs

Replies: 2
Views: 1116
Last post December 11, 2016, 11:19:54 PM
by control3
NHD-0420DZW-AY5 - Proprietary controller, need compatible datasheet reference

Started by MonkeywrenchBoard OLEDs

Replies: 1
Views: 1719
Last post December 29, 2015, 08:27:58 AM
by Saurabh_B
NHD-0420DZW-AY5 vs 763-NHD-0420CW-AY3 for brightness and power consumption

Started by timmwalkBoard OLEDs

Replies: 1
Views: 1746
Last post December 07, 2015, 08:37:17 AM
by Saurabh_B
NHD-0420DZW-AY5 , Clear Display function

Started by Bill_ShepherdBoard OLEDs

Replies: 1
Views: 3550
Last post March 21, 2014, 09:36:29 AM
by Michael_L
NHD-0420DZW-AB5 Excessive Supply Current

Started by peterrashBoard OLEDs

Replies: 2
Views: 2809
Last post May 06, 2014, 12:10:50 PM
by Michael_L