Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 2010 Kenneth Finnegan
// kennethfinnegan.blogspot.com
//
// Serial monitor to print a TTL serial line
// to an HD44780 LCD screen
// Runs on any Arduino platform
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2,3,6,7,4,5);
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 4);
Serial.begin(115200);
// Print a message to the LCD to verify that it's alive.
lcd.print("hello, world!");
}
void loop() {
int i;
// Scan through the four lines available on the LCD
for (i=0; i<4; i++) {
// busy loop until serial data is available
while (Serial.available() < 1) { };
// For some reason, 3rd & 4th lines require -4 cursor position
lcd.setCursor(-4, i);
// Clear the single line with spaces
lcd.print (" ");
lcd.setCursor(-4, i);
int j;
// read up to 16 charaters from serial port
// TODO: filter command codes that don't display
// on the HD44780 displays
for (j=0; j < 16 && Serial.available(); j++) {
char k = Serial.read();
lcd.write(k);
}
// Pause to make reading progress easier
delay (200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment