Files
mixly3-server/arduino-libs/arduino-cli/libraries/LiquidCrystal_I2C/examples/SerialDisplay/applet/SerialDisplay.cpp

49 lines
890 B
C++

/*
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
* an attached LCD.
* DFRobot.com
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "WProgram.h"
void setup();
void loop();
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
Serial.begin(9600);
}
void loop()
{
// when characters arrive over the serial port...
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());
}
}
}
int main(void)
{
init();
setup();
for (;;)
loop();
return 0;
}