You are on page 1of 3

/* SerLCD - NewHaven Display Example Send serial data using the Serial.

print() function to a Newhaven serial enabled display using only 3 wires. This sketch also introduces function declaration. You will need the datasheet for you display to know what the hexidecamal values are for the different commands used. The pinout for the NHD-0216K3Z-FL-GBW is as follows: RX GND VDD o o o SPI/I2C Connetions o o o o o o

The circuit: * LCD RX to Arduino TX * LCD GND to Arduino GND * LCD VDD to Arduino 5V Note: The command values are not in HEX format, they have been changed to there decimal equivalents. Created 24.Jan.2011 By Brandon Honeycutt - The Original Electroids Co. http://thehoneycuttz.com */ void setup() { // set serial baud rate Serial.begin(9600); // turn lcd on lcdOn(); // set lcd contrast to default 40 defltContrast(); // clear lcd clearLCD(); // set cursor to home //cHome(); // set box cursor on bcOn(); // wait 3 secs delay(3000); } void loop(){ // print something to lcd on line one Serial.print("Hello Arduino"); // move cursor to second line Serial.print(0xFE, BYTE); // command flag

Serial.print(69, BYTE); // cursor position command Serial.print(0x40, BYTE); // cursor position // delay text printing 1 sec delay(2000); // print text on line two Serial.print("World!"); delay(2000); // clear lcd clearLCD(); delay(2000); } void clearLCD(){ // clear lcd function Serial.print(0xFE, BYTE); Serial.print(81, BYTE); } void serCmd(){ // command flag Serial.print(0xFE, BYTE); } void defltContrast(){ // set default contrast of 40 Serial.print(0xFE, BYTE); Serial.print(82, BYTE); Serial.print(40, BYTE); } void lcdOn(){ // turn lcd on Serial.print(0xFE, BYTE); // command flag Serial.print(65, BYTE); // on command } void cHome(){ // ser cursor to home position Serial.print(0xFE, BYTE); // command flag Serial.print(70, BYTE); // cursor home command } void bcOn(){

// set box cursor on Serial.print(0xFE, BYTE); // command flag Serial.print(75, BYTE); // cursor on command }

You might also like