961
|
1 /*
|
|
2 * Displays text sent over the serial port (e.g. from the Serial Monitor) on
|
|
3 * an attached LCD.
|
|
4 */
|
|
5 #include <Wire.h>
|
|
6 #include <LiquidCrystal_I2C.h>
|
|
7
|
|
8 #define BACKLIGHT_PIN 13
|
|
9
|
|
10 LiquidCrystal_I2C lcd(0x38); // set the LCD address to 0x38
|
|
11
|
|
12 void setup()
|
|
13 {
|
|
14 pinMode ( BACKLIGHT_PIN, OUTPUT );
|
|
15 lcd.begin (16,2);
|
|
16 digitalWrite ( BACKLIGHT_PIN, HIGH );
|
|
17
|
|
18 Serial.begin(57600);
|
|
19 }
|
|
20
|
|
21 void loop()
|
|
22 {
|
|
23 // when characters arrive over the serial port...
|
|
24 if (Serial.available())
|
|
25 {
|
|
26 // wait a bit for the entire message to arrive
|
|
27 delay(100);
|
|
28 // clear the screen
|
|
29 lcd.clear();
|
|
30 // read all the available characters
|
|
31 while (Serial.available() > 0)
|
|
32 {
|
|
33 // display each character to the LCD
|
|
34 lcd.write(Serial.read());
|
|
35 }
|
|
36 }
|
|
37 }
|