/* Project: LCD2004 I2C module Function: Dispalys symbols and text, you can display your charakters if you enter them in serial monitor Compatible with the Arduino IDE 1.0 */ //*********************************************************** #include //include library code //********************************************************* #if defined(ARDUINO) && ARDUINO >= 100 #define printByte(args) write(args); #else #define printByte(args) print(args,BYTE); #endif uint8_t heart[8] = {0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0};//symbol heart LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);//initialise the LCD 1602 I2C void setup() { Serial.begin(9600); //initialize serial communication at 9600 bps lcd.begin (20, 4);//define the LCD as 20 column by 4 rows //switch on the backlight lcd.setBacklightPin(3, POSITIVE); lcd.setBacklight(HIGH); lcd.createChar(3, heart); lcd.setCursor(0, 0);//sets the cursor to 1 row 1 column for (int i = 0; i < 20; i++) lcd.printByte(3);//prints symbol lcd.setCursor(0, 1);//sets cursor to 2 row 1 column lcd.printByte(3);//prints symbol lcd.print(" Welcome to ");//prints message lcd.printByte(3);//prints symbol lcd.setCursor(0, 2);//sets cursor to 3 row 1 column lcd.printByte(3);//prints symbol lcd.print(" ACOPTEX.COM !!! ");//prints message lcd.printByte(3);//prints symbol lcd.setCursor(0, 3);//sets cursor to 4 row 1 column for (int i = 0; i < 20; i++) lcd.printByte(3);//prints symbol delay (3000);//sets delay for 3 seconds lcd.clear();//clears the screen // Wait and then tell user they can start the Serial Monitor and type in characters to // Display. (Set Serial Monitor option to "No Line Ending") lcd.setCursor(0,0); //Start at character 0 on line 0 lcd.print("Start Serial Monitor"); lcd.setCursor(0,1); lcd.print("Type chars 2 display"); } void loop() { if (Serial.available()) { // wait a bit for the entire message to arrive delay(100); // clear the screen lcd.clear(); // read all the available characters while (Serial.available() > 0) { // display each character to the LCD lcd.write(Serial.read()); } } }