Arduino Code example for Newhaven COG LCD display NHD-C12864WO.
/***************************************************************************** * / Program for writing to NHD-C12864WO display Series with the ST7565P/ST7567 Controller. / This code is written for the Arduino Uno R3 (Micorochip ATmega328P) using 6800 Parallel, 8080 Parallel & Serial Interface / / Newhaven Display invests time and resources providing this open source code, / Please support Newhaven Display by purchasing products from Newhaven Display! * Copyright (c) 2024, Newhaven Display International * * This code is provided as an example only and without any warranty by Newhaven Display. * Newhaven Display accepts no responsibility for any issues resulting from its use. * The developer of the final application incorporating any parts of this * sample code is responsible for ensuring its safe and correct operation * and for any consequences resulting from its use. * See the GNU General Public License for more details. * * Use Vertical Orientation when converting BMP to hex code to display custom image using LCD assistant. *
* Logic level shifters are required to convert the Arduino 5V logic to 3.3V logic
* *****************************************************************************/ /**************************************************** * 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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x80, 0xE0, 0x70, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0xD8, 0xD8, 0xD8, 0xD8, 0xF0, 0xE0, 0x80, 0x00, 0x18, 0x78, 0xE0, 0xC0, 0x00, 0xC0, 0xF0, 0x38, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x38, 0x78, 0xE0, 0x80, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xC0, 0xC0, 0xC0, 0xF8, 0xF8, 0x00, 0x00, 0x18, 0xF8, 0xF0, 0x80, 0xC0, 0xF8, 0x78, 0xC0, 0x80, 0xE0, 0x78, 0x18, 0x00, 0x00, 0x40, 0xD8, 0xD8, 0x98, 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x80, 0xE0, 0xF8, 0xF8, 0x00, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0x98, 0x18, 0x18, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x38, 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, 0x07, 0x07, 0x03, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00, 0x80, 0x81, 0x07, 0x07, 0x03, 0x80, 0x80, 0x00, 0x04, 0x06, 0x07, 0x83, 0x81, 0x01, 0x03, 0x07, 0x06, 0x00, 0x00, 0x07, 0x07, 0x80, 0x80, 0x00, 0x07, 0x07, 0x00, 0x80, 0x80, 0x80, 0x83, 0x87, 0x87, 0x00, 0x00, 0x07, 0x87, 0x83, 0x80, 0x80, 0x80, 0x80, 0x86, 0x06, 0x06, 0x06, 0x06, 0x83, 0x80, 0x00, 0x00, 0x00, 0x07, 0x87, 0x83, 0x80, 0x87, 0x87, 0x80, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0C, 0x19, 0x7B, 0x73, 0xC6, 0xCE, 0x8C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x3F, 0x3F, 0x3F, 0x3F, 0x1E, 0x88, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 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, 0x01, 0x03, 0x3E, 0x3E, 0x07, 0x01, 0x01, 0x00, 0x20, 0x38, 0x1E, 0x1B, 0x19, 0x1F, 0x3C, 0x30, 0x00, 0x00, 0x20, 0x20, 0x20, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x0D, 0x08, 0x0C, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x19, 0x3D, 0x3D, 0x35, 0x35, 0x37, 0x37, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x0E, 0x3F, 0x33, 0x31, 0x31, 0x31, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0E, 0x0E, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x0C, 0x06, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x12, 0x12, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1E, 0x1E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0E, 0x0E, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x18, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x1E, 0x0A, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x16, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1E, 0x1E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x0C, 0x06, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 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, 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, 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, 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, 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 }; /**************************************************** * PINOUT: Arduino Uno -> Chip-On-Glass LCD * ****************************************************/ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // 6800 Parallel Interface // The 8 bit data bus is connected to PORTD 0-7 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #define CS 8 //Active Low Chip Select #define RST 9 //Active Low #define A0 10 //Register Select #define RW 11 //Read/Write Select #define E 12 //Active HIGH Enable #define P_S 18 //Parallel/Serial Select #define C86 19 //MPU Parallel Interface Pin //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // 8080 Parallel Interface // The 8 bit data bus is connected to PORTD 0-7 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #define CS 8 //Active Low Chip Select #define RST 9 //Active Low Reset #define A0 10 //Register Select #define WR 11 //Active LOW Write #define RD 12 //Active Low Read #define P_S 18 //Parallel/Serial Select #define C86 19 //MPU Parallel Interface Pin //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Serial Interface //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #define SCL 6 //Serial Clock #define SI 7 //Serial Data #define CS 8 //Active Low Chip Select #define RST 9 //Active Low Reset #define A0 10 //Register Select #define P_S 18 //Parallel/Serial Select /**************************************************** * Basic Functions * ****************************************************/ unsigned char mode = 1; // 1 = 6800 Parallel // 2 = 8080 Parallel // 3 = Serial void command(unsigned char c){ switch(mode){ case 1: PORTD = c; digitalWrite(A0, LOW); //A0 = 0 digitalWrite(RW, LOW); //RW = 0 digitalWrite(CS, LOW); //CS = 0 digitalWrite(E, HIGH); // E = 1 digitalWrite(E, LOW); // E = 0 digitalWrite(CS, HIGH); //CS = 1 digitalWrite(RW, HIGH); //RW = 1 break; case 2: PORTD = c; digitalWrite(A0, LOW); //A0 = 0 digitalWrite(CS, LOW); //CS = 0 digitalWrite(RD, HIGH); //RD = 1 digitalWrite(WR, LOW); //WR = 0 digitalWrite(WR, HIGH); //WR = 1 digitalWrite(CS, HIGH); //CS = 1 break; case 3: unsigned int n; digitalWrite(A0, LOW); //A0 = 0 digitalWrite(CS, LOW); //CS = 0 for(n=0;n<8;n++){ if((c&0x80)==0x80) digitalWrite(SI, HIGH); //SI = 1 else digitalWrite(SI, LOW); //SI = 0 while(0); c=(c<<1); digitalWrite(SCL, LOW); //SCL = 0 while(0); digitalWrite(SCL, HIGH);//SCL = 1 while(0); digitalWrite(SCL, LOW); //SCL = 0 } digitalWrite(CS, HIGH); //CS = 1 break; } } void data(unsigned char d){ switch(mode){ case 1: PORTD = d; digitalWrite(A0, HIGH); //A0 = 1 digitalWrite(RW, LOW); //RW = 0 digitalWrite(CS, LOW); //CS = 0 digitalWrite(E, HIGH); // E = 1 digitalWrite(E, LOW); // E = 0 digitalWrite(CS, HIGH); //CS = 1 digitalWrite(RW, HIGH); //RW = 1 break; case 2: PORTD = d; digitalWrite(A0, HIGH); //A0 = 1 digitalWrite(CS, LOW); //CS = 0 digitalWrite(RD, HIGH); //RD = 1 digitalWrite(WR, LOW); //WR = 0 digitalWrite(WR, HIGH); //WR = 1 digitalWrite(CS, HIGH); //CS = 1 break; case 3: unsigned int n; digitalWrite(A0, HIGH); //A0 = 1 digitalWrite(CS, LOW); //CS = 0 for(n=0;n<8;n++){ if((d&0x80)==0x80) digitalWrite(SI, HIGH); //SI = 1 else digitalWrite(SI, LOW); //SI = 0 while(0); d=(d<<1); digitalWrite(SCL, LOW); //SCL = 0 while(0); digitalWrite(SCL, HIGH);//SCL = 1 while(0); digitalWrite(SCL, LOW); //SCL = 0 } digitalWrite(CS, HIGH); //CS = 1 break; } } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Show Image (Full Screen) //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void dispPic(unsigned char *lcd_string) { unsigned int i,j; unsigned char page = 0xB0; command(0xAE); //Display OFF command(0x40); //Display start address + 0x40 command(0xA0); //Ram->SEG output = normal command(0xC0); //COM direction scan = normal for(i=0;i<8;i++){ //64 pixel display / 8 pixels per page = 8 pages command(page); //send page address command(0x10); //column address upper 4 bits + 0x10 command(0x00); //column address lower 4 bits + 0x00 for(j=0;j<128;j++){ //128 columns wide data(*lcd_string); //send picture data lcd_string++; } page++; //after 128 columns, go to next page } command(0xAF); } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Show Image (Full Screen) Rotated 180 degrees //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= /* NOTE: * Display = 128 pixels wide. ST7565 IC = 132 addressable pixels wide. * When COM & SEG orientation is reversed to flip display, the Column * Address is shifted by 4 pixels in order to write to displays * configured 128 SEG lines / pixels. */ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void dispPic180(unsigned char *lcd_string) { unsigned int i,j; unsigned char page = 0xB0; command(0xAE); //Display OFF command(0x40); //Display start address + 0x40 command(0xA1); //Ram->SEG output = reverse command(0xC8); //COM direction scan = reverse for(i=0;i<8;i++){ //64 pixel display / 8 pixels per page = 8 pages command(page); //send page address command(0x10); //column address upper 4 bits + 0x10 command(0x04); //column address lower 4 bits + 0x04 (Shifted to keep entire image within Active Area) for(j=0;j<128;j++){ //128 columns wide data(*lcd_string); //send picture data lcd_string++; } page++; //after 128 columns, go to next page } command(0xAF); } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Clear Screen //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void ClearLCD() { unsigned int i,j; unsigned char page = 0xB0; command(0xAE); //Display OFF command(0x40); //Display start address + 0x40 command(0xA0); //Ram->SEG output = normal command(0xC0); //COM direction scan = normal for(i=0;i<8;i++){ //64 pixel display / 8 pixels per page = 8 pages command(page); //send page address command(0x10); //column address upper 4 bits + 0x10 command(0x00); //column address lower 4 bits + 0x00 for(j=0;j<132;j++){ //128 columns wide data(0x00); //write 0x00 (clear) pixels } page++; //after 128 columns, go to next page } command(0xAF); //Display ON } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Fill Screen //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void Fill() { unsigned int i,j; unsigned char page = 0xB0; command(0xAE); //Display OFF command(0x40); //Display start address + 0x40 command(0xA0); //Ram->SEG output = normal command(0xC0); //COM direction scan = normal for(i=0;i<8;i++){ //64 pixel display / 8 pixels per page = 8 pages command(page); //send page address command(0x10); //column address upper 4 bits + 0x10 command(0x00); //column address lower 4 bits + 0x00 for(j=0;j<128;j++){ //128 columns wide data(0xFF); //write 0xFF pixels } page++; //after 128 columns, go to next page } command(0xAF); //Display ON } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Border Function //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void Border() { unsigned int i,j; unsigned char page = 0xB0; command(0xAE); //Display OFF command(0x40); //Display start address + 0x40 command(0xA0); //Ram->SEG output = normal command(0xC0); //COM direction scan = normal for(i=0;i<8;i++){ //64 pixel display / 8 pixels per page = 8 pages command(page); //send page address command(0x10); //column address upper 4 bits + 0x10 command(0x00); //column address lower 4 bits + 0x00 data(0xFF); //Establish Left Border of Display (Column 0) for(j=0;j<126;j++){ //126 columns wide (Columns 1-126) if (i==0){ //if First Page (Page 1) data(0x01); //Start to establish Top Border of Display } else if (i==7){ //if Last Page (Page 8) data(0x80); //Start to establish Bottom Border of Display } else { data(0x00); //Fill interior with empty pixels } } data(0xFF); //Establish Right Border of Display (Column 127) page++; //after 128 columns, go to next page } command(0xAF); //Display ON } /**************************************************** * Initialization Routine * ****************************************************/ void init1(){ digitalWrite(RST, LOW); delay(100); digitalWrite(RST, HIGH); delay(100); command(0xA2); //LCD drive voltage bias ratio. command(0xA0); //Ram->SEG output = normal command(0xC0); //COM direction scan = normal command(0x40); //Display Start Line command(0x25); //Resistor Ratio Set command(0x10); //column address set (upper bit) Double Byte: 1 of 2 command(0x00); //column address set (lower bit) Double Byte: 2 of 2 command(0x81); //Electronic Volume Command (set contrast) Double Byte: 1 of 2 command(0x25); //Electronic Volume value (contrast value) Double Byte: 2 of 2 command(0x2F); //Power Control Set command(0xAF); //Display ON } /***************************************************** * Setup Function, to run once * *****************************************************/ void setup() { DDRB = 0xFF; //Enable ports PB0-PB7 on Arduino Uno DDRC = 0xFF; //Enable ports PC0-PC7 on Arduino Uno DDRD = 0xFF; //Enable ports PD0-PD7 on Arduino Uno digitalWrite(CS, HIGH); digitalWrite(A0, HIGH); digitalWrite(RST, HIGH); switch(mode) { case 1: digitalWrite(C86, HIGH); digitalWrite(P_S, HIGH); digitalWrite(E, HIGH); digitalWrite(RW, HIGH); break; case 2: digitalWrite(C86, LOW); digitalWrite(P_S, HIGH); digitalWrite(WR, HIGH); digitalWrite(RD, HIGH); break; case 3: digitalWrite(P_S, LOW); digitalWrite(SCK, LOW); digitalWrite(SI, HIGH); } init1(); ClearLCD(); delay(50); } /***************************************************** * Loop Function, to run repeatedly * *****************************************************/ void loop() { command(0xA5); //All points ON delay(1000); command(0xA4); //Normal Display delay(1000); Border(); delay(1000); ClearLCD(); delay(1000); dispPic(nhd); delay(1000); ClearLCD(); delay(1000); dispPic180(nhd); delay(1000); ClearLCD(); delay(1000); }