Guest User

Untitled

a guest
Jun 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. // 2010 Kenneth Finnegan
  2. // kennethfinnegan.blogspot.com
  3. //
  4. // Serial monitor to print a TTL serial line
  5. // to an HD44780 LCD screen
  6. // Runs on any Arduino platform
  7.  
  8. #include <LiquidCrystal.h>
  9.  
  10. // initialize the library with the numbers of the interface pins
  11. LiquidCrystal lcd(2,3,6,7,4,5);
  12.  
  13. void setup() {
  14. // set up the LCD's number of rows and columns:
  15. lcd.begin(16, 4);
  16. Serial.begin(115200);
  17. // Print a message to the LCD to verify that it's alive.
  18. lcd.print("hello, world!");
  19. }
  20.  
  21. void loop() {
  22. int i;
  23. // Scan through the four lines available on the LCD
  24. for (i=0; i<4; i++) {
  25. // busy loop until serial data is available
  26. while (Serial.available() < 1) { };
  27. // For some reason, 3rd & 4th lines require -4 cursor position
  28. lcd.setCursor(-4, i);
  29. // Clear the single line with spaces
  30. lcd.print (" ");
  31. lcd.setCursor(-4, i);
  32. int j;
  33. // read up to 16 charaters from serial port
  34. // TODO: filter command codes that don't display
  35. // on the HD44780 displays
  36. for (j=0; j < 16 && Serial.available(); j++) {
  37. char k = Serial.read();
  38. lcd.write(k);
  39. }
  40. // Pause to make reading progress easier
  41. delay (200);
  42. }
  43. }
Add Comment
Please, Sign In to add comment