I've connected a 40x4 LCD to my arduino and i use the LiquidCrystal library. While the LCD acts as 2 40x2 displays and i didn't figure out how the LiquidCrystal lib would handle that i've written my code so it should handle it. In the loop i wanted to Serial.println the running integer i. However when i put in that line it prints nothing and at the display it just shows the first character ... no more than this. Why does the arduino strike to Serial.println(i); ????
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd2(12, 10, 5, 4, 3, 2);
void setup(){
// set up the LCD's number of rows and columns:
lcd.begin(40, 2);
lcd2.begin(40, 2);
// initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
int cha;
int i=1;
// 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();
lcd2.clear();;
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
cha=Serial.read();
if (i<=80){
lcd.write(cha);
}else{
lcd2.write(cha);
}
i++;
Serial.println(i);
}
}
}