Working under Arduino 0.22.
I have an application that uses a 40x4 display (LiquidCrystal440 library) that works if I have either Arduino Serial Monitor or HyperTerminal connected and hit [ENTER].
it should configure the display and print "Ready -" on the first line.
As is the led on pin 13 repeatedly flashes what looks like 3 times very rapidly. Behaviour is the same whether I power it using the USB or the power input.
once I hit an [ENTER] the program runs fine. Comment out all the serial commands and the problem persists.
I am wanting to build a free standing communication device and won't have a computer to send an [ENTER] to the serial port...
I am suspecting that this is a problem with the bootloader.
#include <LiquidCrystal440.h>
// Try to exercise everything in LiquidCrystal for test purposes--: You should be able to modify the first 4 lines
// of code to test different options
uint8_t nRows = 4; //number of rows on LCD
uint8_t nColumns =40; //number of columns
int serDat;
char line[4][40];
int linect;
int linepos[4];
LiquidCrystal lcd(12,9,11,10,5,4,3,2); // RS, RW, EN1, EN2, D4, D5, D6, D7 4x40 display.
//=====for a 4x40 LCD with 2 HD44780 type chips and 17 pin interface in 2 rows of 9; the pins are not arranged for
// use with a breadboard, although you could solder a female socket onto the LCD board and use wires inserted
// female sockets or (as I did) to solder in stackable headers so that you can use the breadboard but
// also can plug it into the 2 rows of digital sockets on the Mega.
// LCD Arduino Signal
// 18
// 17
// 16 not used
// 15 10 En2 -- enable the 2nd HD44780 chip which controls the bottom 2 rows of the display
// 14 +5 +5V
// 13 GND Gnd
// 12 -- Contrast resistor to Gnd
// 11 12 RS
// 10 9 RW -- could be strapped to Gnd
// 9 11 En1 -- enable the 1st HD44780 which controls the top 2 rows
// 5-8 N/C Data 0-3 not used in 4 bit modes
// 1-4 5,4,3,2 Data 4-7
void setup(void) {
int ct;
pinMode(13,OUTPUT);
Serial.begin(9600);
lcd.begin(nColumns,nRows);
delay(500);
lcd.println("Ready -");
linect = 1;
lcd.blink();
for (ct=0; ct<40; ct++) {
line[0][ct]=0;
line[1][ct]=0;
line[2][ct]=0;
line[3][ct]=0;
}
linepos[0]=0;
linepos[1]=0;
linepos[2]=0;
linepos[3]=0;
}
void loop(void) {
serDat = Serial.read();
if (serDat >0) {
Serial.println(serDat);
}
if (serDat==13) {
lcd.noBlink();
Serial.println(linect);
if (linect > 2) {
screenScroll();
}
else {
lcd.println();
linect += 1;
}
lcd.blink();
}
if (serDat== 8) {
Serial.println(linepos[linect]);
linepos[linect] -= 1;
lcd.setCursor(linepos[linect],linect);
lcd.print(" ");
line[linect][linepos[linect]] = 0;
lcd.setCursor(0,linect);
lcd.print(line[linect]);
}
if (serDat > 31) {
//lcd.print(serDat, BYTE);
line[linect][linepos[linect]]= serDat;
linepos[linect] += 1;
lcd.setCursor(0,linect);
lcd.print(line[linect]);
}
}
void screenScroll() {
Serial.println("ScreenScroll");
int ct;
for(ct=0;ct < 40; ct++) {
line[0][ct] = line[1][ct];
line[1][ct] = line[2][ct];
line[2][ct] = line[3][ct];
line[3][ct]=0;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print(line[0]);
lcd.setCursor(0,1);
lcd.print(line[1]);
lcd.setCursor(0,2);
lcd.print(line[2]);
lcd.setCursor(0,3);
lcd.print(line[3]);
linepos[3]=0;
//lcd.print("$");
}