Below is my very simple serial monitor testing code. It will just take whatever comes in from the serial line and write it to the display and wrap to the beginning every 16 character.
/* Testing code for using a 16x1 LCD display with Arduino LiquidCrystal library. LCD used is a Displaytech 161A 16x1 display. See this page for an explanation how it works (161A is a "Type-1"): http://web.alfredstate.edu/weimandn/lcd/lcd_addressing/lcd_addressing_index.html */ #includeLiquidCrystal lcd(12, 11, 5, 4, 3, 2); int c=0; int r=0; void setup(){ lcd.begin(8, 2); Serial.begin(9600); lcd.clear(); lcd.cursor(); } void loop() { int i=0; if (Serial.available()) { while (Serial.available() > 0) { i=Serial.read(); if (i==-1) break; lcd.write(i); c++; if (c==8) { r=(r==1 ? 0 : 1); c=0; lcd.setCursor(c,r); } Serial.print(c); Serial.print("\t"); Serial.print(r); Serial.println(" "); } } }
No comments:
Post a Comment