Author Topic: NHD-0420DZW-AB5  (Read 1146 times)

nathanbabu

  • Jr. Member
  • **
  • Posts: 16
  • Karma: 0
    • View Profile
NHD-0420DZW-AB5
« on: December 27, 2016, 05:11:08 AM »
Hi Sir,
         I want to use the OLED using I2C Concept Please provide sample code and Connection diagram for hardware connection between arduino and our OLED Display.

Thanks & Regards,
Padmanathan.P

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: NHD-0420DZW-AB5
« Reply #1 on: December 27, 2016, 11:25:45 AM »
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.

nathanbabu

  • Jr. Member
  • **
  • Posts: 16
  • Karma: 0
    • View Profile
Re: NHD-0420DZW-AB5
« Reply #2 on: December 29, 2016, 06:01:34 AM »
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

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: NHD-0420DZW-AB5
« Reply #3 on: December 29, 2016, 08:02:00 AM »
Here is an example SPI code for the serial OLED displays:
Code: [Select]
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);
}

}
}

nathanbabu

  • Jr. Member
  • **
  • Posts: 16
  • Karma: 0
    • View Profile
Re: NHD-0420DZW-AB5
« Reply #4 on: December 29, 2016, 09:08:18 PM »
Hi Sir,

        Thanks for your reply.

Did you have any reference code for arduino

Regards,
Padmanathan.P

 

Questions regarding NHD‐0220DZW‐AY5 & NHD‐0420DZW‐AY5

Started by tseyfarthBoard OLEDs

Replies: 3
Views: 2864
Last post August 20, 2015, 09:51:26 AM
by Saurabh_B
NHD‐0420DZW‐AB5 Lines

Started by RickJBoard OLEDs

Replies: 1
Views: 2275
Last post January 09, 2015, 04:18:32 PM
by Michael_L
NHD‐0420DZW‐AY5 SPI Interface

Started by vinaykBoard OLEDs

Replies: 0
Views: 2042
Last post October 26, 2015, 05:13:10 AM
by vinayk
NHD-0420DZW-AG5 - Display "sometimes" shows only 2 lines

Started by stylonurusBoard OLEDs

Replies: 5
Views: 5568
Last post June 18, 2014, 10:09:49 AM
by Michael_L
NHD‐0420DZW‐AY5 - Power consumption and luminance difference 3.3V/5.0V?

Started by MonkeywrenchBoard OLEDs

Replies: 0
Views: 1455
Last post November 20, 2015, 06:40:16 PM
by Monkeywrench