NHD-0420E2Z-NSW-BBW is displaying Japanese Characters instead of my string

Comments

1 comment

  • Michael_L

    Hi Shane,

    Did you receive my response to your email yesterday regarding this?  I will copy it and post it below just in case you did not:

    That Arduino library is written for Hitachi HD44780 controller, whereas our display uses the Sitronix ST7066U.  There are some minor timing differences between the two controllers, which can be seen in their respective datasheets. However, I have used this library with our displays before, but I believe it was using an 8-bit interface.  The problem here is not our display but in fact the library you are using.  If it’s possible, try using an 8-bit interface with that library, otherwise you may refer to the attached 4-bit interface Arduino code I have for our 4x20 character displays.

    Note:  in the code you will see it mentions “character OLED” display, but the code works for our LCDs as well (I just tested it again to be sure).

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

    (c)2014 Michael D. 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 PORTD[3..0] of the Arduino Uno

    int RS =  9;     // RS signal connected to digital pin 9
    int RW =  10;    // R/W signal connected to digital pin 10
    int  E =  11;    // E signal connected to digital pin 11

    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)

       PORTD = (c>>4);
       digitalWrite(RS, LOW);
       toggle();
       PORTD = c;
       toggle();
    }

    void data(char d)
    {
       PORTD = (d>>4);
       digitalWrite(RS, HIGH);
       toggle();
       PORTD = 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()
    {
       DDRD = 0xFF;    //set PORTD (data bus) as output
       PORTD = 0x00;   //initialize PORTD to 0x00
       DDRB = 0xFF;    //set PORTB (control lines) as output
       PORTB = 0x00;   //initialize PORTB to 0x00
       delay(5);
       toggle();
       delay(5);
       PORTD = 0x2;
       toggle();
       command(0x28);
       PORTD = 0x0;
       toggle();
       PORTD = 0x8;
       toggle();
       PORTD = 0x0;
       toggle();
       PORTD = 0x1;
       toggle();
       delay(5);
       PORTD = 0x0;
       toggle();
       PORTD = 0x6;
       toggle();
       PORTD = 0x0;
       toggle();
       PORTD = 0x2;
       toggle();
       PORTD = 0x0;
       toggle();
       PORTD = 0xC;
       toggle();
       delay(10);
    }

    void loop()

      disp();
      delay(3000);
    }
    0

Please sign in to leave a comment.