arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

SerialDisplay.pde (812B)


      1 /*
      2  * Displays text sent over the serial port (e.g. from the Serial Monitor) on
      3  * an attached LCD.
      4  * YWROBOT
      5  *Compatible with the Arduino IDE 1.0
      6  *Library version:1.1
      7  */
      8 #include <Wire.h> 
      9 #include <LiquidCrystal_I2C.h>
     10 
     11 LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
     12 
     13 void setup()
     14 {
     15   lcd.init();                      // initialize the lcd 
     16   lcd.backlight();
     17   Serial.begin(9600);
     18 }
     19 
     20 void loop()
     21 {
     22   // when characters arrive over the serial port...
     23   if (Serial.available()) {
     24     // wait a bit for the entire message to arrive
     25     delay(100);
     26     // clear the screen
     27     lcd.clear();
     28     // read all the available characters
     29     while (Serial.available() > 0) {
     30       // display each character to the LCD
     31       lcd.write(Serial.read());
     32     }
     33   }
     34 }