// Includes the library code
#include <LiquidCrystal.h>
#include <SerialTransfer.h>
// Defines the LCD's parameters: (rs, enable, d4, d5, d6, d7)
LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
// Defines the first user defined character - :)
byte smile1[8] = {
0b00000,
0b11010,
0b11001,
0b00001,
0b00001,
0b11001,
0b11010,
0b00000
};
byte inputChar[8];
void setup() {
int i;
// Set up the LCD's number of columns and rows
lcd.begin(16, 2);
// Creates the user defined characters - :) and ;)
lcd.createChar(1, smile1);
// Prints the first part of the message to the LCD
lcd.print("Hello everyone!");
delay(2000);
lcd.clear();
// Sets the cursor to column 0, row 2
// (note: the counting of rows and columns begins with 0)
lcd.setCursor(0, 0);
// Prints the second part of the message to the LCD
lcd.print("This is...");
delay(2000);
// Clears the LCD screen
// Sets the cursor to column 3, row 1 (so that it appears
// in the middle of the LCD)
lcd.setCursor(0, 1);
// Prints the website's name and characters separately
lcd.print("A Serial Test");
delay(1000);
// Prints the ending message
lcd.setCursor(0, 0);
for (int i = 0; i < 16; i++) {
lcd.scrollDisplayLeft();
delay(400);
}
lcd.clear();
lcd.setCursor(0, 0);
// Prints the second part of the message to the LCD
lcd.print("Beginning");
lcd.setCursor(0, 1);
lcd.print("Trasmission");
delay(2000);
lcd.clear();
// Print trasmitted char
lcd.clear();
lcd.setCursor(0, 0);
// Prints the second part of the message to the LCD
lcd.print("Transmitting...");
lcd.setCursor(0, 1);
lcd.write(byte(1));
delay(2000);
lcd.clear();
//Prepare Serial Trasmission
Serial.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
for (i=0;i<8;i++) {
Serial2.write(smile1[i]);
}
delay(2000);
//receiving
if (Serial3.available()) {
while (Serial3.available() >0) {
Serial3.readBytes(inputChar,8);
}
}
for (i=0;i<8;i++) {
Serial.print(inputChar[i]);
}
// Print received char
lcd.clear();
lcd.setCursor(0, 0);
// Prints the second part of the message to the LCD
lcd.print("Received: ");
lcd.createChar(2, inputChar);
lcd.setCursor(0, 1);
lcd.write(byte(2));
delay(2000);
}
void loop() {
}