NHD-0420DZW-AB5

Comments

5 comments

  • Saurabh_B

    Hello Padmanthan,

    This display does not support an I2C interface, you would need to use SPI or Parallel.
    If you are looking to use I2C i would recommend our Slim OLED displays.

    0
  • nathanbabu

    Thanks for your reply..

    Kindly provide sample code for SPI Interface. And i am modified Jumper settings as per the Specification sheet in your website.

    And  I am using arduino for this interface programming.

    Regards,
    Padmanathan.P

    0
  • Saurabh_B

    Here is an example SPI code for the serial OLED displays:

    sbit SCL = P3^4;   //Serial Clock Pin
    sbit SDOUT = P1^0; // Serial Data Out
    sbit SDIN = P1^1; // Serial Data In
    sbit C_S = P3^3; // Chip Select

    /*************************************************
    ******** CHARACTER STRINGS ***********************  You can also use these to send a line of text you would like to display
    ************************************************** 
    *************************************************/
    char const text1[] = ("Testing OLED Display")
    char const text2[] = ("NewHaven Display L 2")
    char const text3[] = ("    Line  3 Test    ")
    char const text4[] = ("       Line 4       ")

    void delay(unsigned int n) //Delay subroutine n* 250 cycles
    {
    unsigned int i,j;
    for (i=0;i<n;i++)
       for (j=0;j<250;j++)
       {;}
    }
     

    void WriteCommand(unsigned char ins)
    {
    unsigned char i;
    C_S=0;
    SCL = 0;
    SDOUT = 0;  //RS = 0 (Command)
    SCL = 1; //RS registered
    SCL = 0;
    SDOUT = 0;  //RW = 0
    SCL = 1; //RW registered
    SCL = 0;

    for (i=0x80;i;i>>=1)
    {
    if((ins&0x80)==0x80)
    SDOUT = 1;
    else
    SDOUT = 0;
    ins=(ins<<1);
    SCL = 0;
    SCL = 1;
    SCL = 0;
    }

        C_S=1;
    }

    void WriteDataInit() // first write data command while setting Register Select
    {

    C_S=0;
    SCL = 0;
    SDOUT = 1; //RS = 1 (Data)
    SCL = 0; //RS registered
    SCL = 1;
    SCL = 0;
    SDOUT = 0;  //RW = 0
    SCL = 1; //RS registered
    SCL = 0;

    }
    void WriteData(unsigned char dat)  //continuous data stream
    {
    unsigned char i;
    for (i=0x80;i;i>>=1)
    {
    if((dat&0x80)==0x80)
    SDOUT = 1;
    else
    SDOUT = 0;
    dat=(dat<<1);
    SCL = 0;
    SCL = 1;
    SCL = 0;
    }

    }

    void Show_String(){
    WriteCommand(0x01); // Clear Display
    WriteCommand(0x02); // Return Home
    WriteDataInit();
    for( int i = 0; i< 20; i++){
    WriteData(text1[i]);
      }
      WriteCommand(0xC0); // Second Line
      WriteDataInit();
      for(int i = 0; i < 20; i++){
    WriteData(text2[i]);
      }
      WriteCommand(0x94); // Third Line
      WriteDataInit();
      for (int i = 0; i<20; i++){
    WriteData(text3[i]);
      }

      WriteCommand(0xD4); // Fourth Line
      WriteDataInit();
      for(int i = 0; i < 20; i++){
    WriteData(text4[i]);
        }
    }

    void init()
    {
    WriteCommand(0x38);//function set
    delay(30);
    WriteCommand(0x06);//entry mode set
    delay(30);
    WriteCommand(0x02);//return home
    delay(30);
    WriteCommand(0x01);//clear display
    delay(30);
    WriteCommand(0x0c);//display on
    delay(30);
    WriteCommand(0x80);//line 1 character 1
    delay(30);
    }


    void main()
    {
    char i=0x21, j;



    init();

    //Show_String();
    //delay(1000):
    while(1)
    {
    C_S = 1;
    WriteCommand(0x80); //Line 1

    WriteDataInit();
    //WriteDataInit() must only be executed once before starting to write data
    //if WriteDataInit() is executed between writes, the display will recognize the two bits as data bits and not RS/RW bits. 
    for(j=0; j<20; j++)
    {
    WriteData(i++);
    delay(10);
    }

    C_S = 1;
    //Pulling C_S High means write data is completed
    //if next instruction to the display is data, must use WriteDataInit() first
    //if write command is executed without pulling C_S high, it will recognize the following instruction on the bus as data regardless
    WriteCommand(0xC0); //Line 2

    WriteDataInit();
    for(j=0; j<20; j++)
    {
    WriteData(i++);
    delay(10);
    }

    C_S = 1;
    WriteCommand(0x94); //Line 3

    WriteDataInit();
    for(j=0; j<20; j++)
    {
    WriteData(i++);
    delay(10);
    }


    C_S = 1;
    WriteCommand(0xD4); //Line 4

    WriteDataInit();
    for(j=0; j<20; j++)
    {
    WriteData(i++);
    delay(10);
    }

    }
    }
    0
  • nathanbabu

    Hi Sir,

    Thanks for your reply.

    Did you have any reference code for arduino?

    Regards,
    Padmanathan.P

    0
  • Engineering Support
    Community moderator

    Update: 

    Take a look at our Arduino code example for NHD-0420DZW displays for serial communication: 

    https://support.newhavendisplay.com/hc/en-us/articles/4413877064855-NHD-0420DZW-Serial-with-Arduino 

    0

Please sign in to leave a comment.