Author Topic: NHD-C12864A1Z-FS(RGB)-FBW-HT1 Arduino Uno example  (Read 158 times)

jainvikas8

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
NHD-C12864A1Z-FS(RGB)-FBW-HT1 Arduino Uno example
« on: November 21, 2018, 05:22:25 AM »
Hi guys,

   Wonder if there any example code for Arduino Uno to work with NHD-C12864A1Z-FS(RGB)-FBW-HT1 Display?

Thanks.
 
Product link http://www.newhavendisplay.com/nhdc12864a1zfsrgbfbwht1-p-3896.html

Alee_S

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
    • View Profile
Re: NHD-C12864A1Z-FS(RGB)-FBW-HT1 Arduino Uno example
« Reply #1 on: December 12, 2018, 11:06:22 AM »
Hello there!

I have attached some sample code to help get you started. Although this code is written for a different model, it will work for the NHD-C12864A1Z-FS(RGB)-FBW-HT1 display as well.

Hope this helps!

Code: [Select]
/*
 *  Program written for C12864A1Z-FSW-FBW-HTT  Chip-On-Glass Display.
 *  Code written for Arduino Uno.
 *  Code written for Serial Interface.
*/

/****************************************************
*               Pinout on Arduino Uno               *
*****************************************************/

#define RES 8   //Reset signal
#define CS  9   //Chip select signal
#define RS 10   //Register select signal
#define SC 11   //Serial clock signal
#define SI 12   //Serial data signal

/****************************************************
*               Hex Table for NHD Pic               *
*****************************************************/

unsigned char nhd[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x07, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x12, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x01, 0x80, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x81, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x07, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x80, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x01, 0x80, 0x38, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x38, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x07, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1B, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x81, 0x38, 0x00, 0x00,
0x00, 0x00, 0x02, 0x1F, 0x01, 0x78, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x3C, 0x03, 0xE0, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x30, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x07, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3F, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3F, 0x80, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x07, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x18, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x80, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x80, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x83, 0xF0, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x3F, 0x87, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3F, 0x87, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x87, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3D, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x80, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x35, 0x80, 0x18, 0x00, 0x00, 0x00, 0x00, 0x16, 0x35, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x37, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x37, 0x86, 0x40, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3F, 0x83, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0xC0, 0x00, 0x00,
0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x3F, 0x07, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x33, 0x87, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x83, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x31, 0x80, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x87, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3F, 0x87, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3F, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x06, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xD8, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x00, 0x19, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x7B, 0x98, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x73, 0x18, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0xC6, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xCE, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x8C, 0x7C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x0C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x7C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x0C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x03, 0x0C, 0x38, 0x00, 0x00,
0x00, 0x00, 0x1E, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x88, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

/****************************************************
*                 Function Commands                  *
*****************************************************/

void data_write(unsigned char d) //Data Output Serial Interface
{
unsigned int n;
digitalWrite(CS, LOW);
digitalWrite(RS, HIGH);
for(n=0;n<8;n++){
if((d&0x80)==0x80)
digitalWrite(SI, HIGH);
else
digitalWrite(SI, LOW);
while(0);
d=(d<<1);
digitalWrite(SC, LOW);
while(0);
digitalWrite(SC, HIGH);
while(0);
digitalWrite(SC, LOW);
}
digitalWrite(CS, HIGH);
}


void comm_write(unsigned char d) //Command Output Serial Interface
{
unsigned int n;
digitalWrite(CS, LOW);
digitalWrite(RS, LOW);
for(n=0;n<8;n++){
if((d&0x80)==0x80)
digitalWrite(SI, HIGH);
else
digitalWrite(SI, LOW);
while(0);
d=(d<<1);
digitalWrite(SC, LOW);
while(0);
digitalWrite(SC, HIGH);
while(0);
digitalWrite(SC, LOW);
}
digitalWrite(CS, HIGH);
}


void DispPic(unsigned char *lcd_string)  //Function to write pic data into display
{
unsigned int i,j,x;
unsigned char count;
unsigned char page = 0xB0;
comm_write(0x40);
for(i=0;i<8;i++){
comm_write(page); 
comm_write(0x10);
comm_write(0x00);
for(j=0;j<128;j++)
{
for(x=8;x>i;x--)
{lcd_string++;}

      data_write(*lcd_string);

for(x=0;x<i;x++)
{lcd_string++;}
   
}
for(x=0;x<1024;x++)lcd_string--;
page++; count++;
    }
comm_write(0xAF);
}


void ClearLCD(unsigned char *lcd_string)  //Function to clear display
{
unsigned int i,j,x;
unsigned char count;
unsigned char page = 0xB0;
comm_write(0x40);
for(i=0;i<8;i++){
comm_write(page);   
comm_write(0x10);
comm_write(0x00);
for(j=0;j<128;j++)
{
for(x=8;x>i;x--)
{lcd_string++;}

data_write(0x00);
     

for(x=0;x<i;x++)
{lcd_string++;}

}
for(x=0;x<1024;x++)lcd_string--;
page++; count++;
    }
comm_write(0xAF);
}


/****************************************************
*           Initialization For controller           *
*****************************************************/

void init_LCD()  {
comm_write(0xA1);   // ADC select
comm_write(0xAE);   // Display OFF
comm_write(0xC8);   // COM direction scan
comm_write(0xA2);   // LCD bias set
comm_write(0x2F);   // Power Control set
comm_write(0x26);   // Resistor Ratio Set
comm_write(0x81);   // Electronic Volume Command (set contrast) Double Btye: 1 of 2
comm_write(0x11);   // Electronic Volume value (contrast value) Double Byte: 2 of 2
comm_write(0xAF);   // Display ON
}

/*****************************************************
*           Setup Function, to run once              *
*****************************************************/

void setup() {
  DDRD = 0xFF;          // configure PORTD as output
  pinMode(RES, OUTPUT); // configure RES as output
  pinMode(CS, OUTPUT);  // configure CS as output
  pinMode(RS, OUTPUT);  // configure RS as output
  pinMode(SC, OUTPUT);  // configure SC as output
  pinMode(SI, OUTPUT);  // configure SI as output
  digitalWrite(RES, LOW);           
  delay(100);                     
  digitalWrite(RES, HIGH);           
  delay(100);                     
}

/*****************************************************
*           Loop Function, to run repeatedly         *
*****************************************************/

void loop() {
delay(10);
init_LCD();
while(1)
{
    ClearLCD(nhd);
    delay(500);    //delay of 500 ms
DispPic(nhd);
delay(1000);   //delay of 1000 ms or 1 second
}
}

 

Arduino LCD library not working with newhaven display NHD‐0420H1Z‐FL‐GWB-3V3

Started by c2hollowBoard Character LCDs

Replies: 9
Views: 16419
Last post July 10, 2014, 08:46:06 AM
by Michael_L
NHD‐C12864A1Z‐FS(RGB)‐FBW‐HT1 Initialization

Started by BMohlmanBoard Graphic LCDs

Replies: 5
Views: 6825
Last post January 13, 2016, 07:44:16 AM
by Paul_B
MOVED: 320x240 sunlight readable dispaly to arduino + library

Started by Michael_LBoard Customer Projects

Replies: 0
Views: 5124
Last post October 23, 2015, 11:45:28 AM
by Michael_L
Arduino demo code for running the NHD-0420DZW-AB5 OLED display via SPI

Started by llameroBoard OLEDs

Replies: 1
Views: 2380
Last post May 21, 2018, 11:28:30 AM
by Ted_M
How do I stack a DAC shield between a 4.3" LCD Display and an Arduino Mega 2560?

Started by wa6htpBoard Customer Projects

Replies: 1
Views: 778
Last post September 19, 2018, 09:14:45 AM
by Ted_M