Hi all,
I've been noticing my LCD doing some very strange (and harder to track down) things on occasion
#include <LCD4Bit.h>
LCD4Bit lcd = LCD4Bit(2);
int serbyte = 0;
void setup() {
lcd.init();
Serial.begin(115200);
}
void loop() {
serbyte = Serial.read();
if (serbyte != -1 && serbyte != 94 && serbyte != 37)
{
lcd.print(serbyte);
Serial.print(serbyte); //echo back to the comp so i can find the stupid bug
Serial.print("."); //make it easier to read
delay(20);
}
if (serbyte == 94)
{
//lets make ^ the clear char, easy to type, not used often in mp3 titles
lcd.init(); //we need to re-init after a suspend, and it doesn't seem to have any performance hit, so lets use init instead of clear
delay(100);
}
if (serbyte == 37)
{
//and lets make the % the newline char, again easy to type, and not used often in mp3 titles
lcd.cursorTo(2, 0);
delay(100);
}
}
It usually works as intended, stuff gets piped over serial, it takes it and prints it to the LCD, and back to serial
very rarely it prints the wrong thing, here's an example, if I echo "^Avenged Sevenfold%City of Evil" to the serial port, here's what I get back (ascii is my doing, it's what should be printed)
A v e n g e d (wrong though, prints as Ave* Sevenfold)
65.118.101.235.149.145.129.
S e v e n f o l d
83.101.118.101.110.102.111.108.100.
C i t y
67.105.116.121.
sp O f
32.111.102.
sp E v i l
32.69.118.105.108.
does this make sense to anyone? almost as important, has anyone else seen a problem like this?
I havn't tested enough to be sure, but after only a few test runs, I havn't been able to make it happen with a slower baud rate (using 57600 instead of 115200) could that have something to do with it?