Hello,
I recently ordered a 4x20 lcd (CFAH2004A-TFH-JT) from Crystalfontz and tried to get it running using Jonathan's modified version of the LCD4Bit library. However, none of the characters I print seem to show up.
Here's what happens:
I turn on the LCD and arduino separately. When I turn on the LCD, the potentiometer I'm using on the contrast pin is all the way toward ground so black boxes show up on the first and third lines. I fade them out until I can barely see them. Once the arduino is turned on, the black boxes go away entirely (which leads me to believe lcd.clear() is working), but none of the characters that are supposed to print show up. If I move the potentiometer all the way back toward ground the black boxes are still gone. Turning off and on the LCD always brings the boxes back and resetting the arduino always clears them.
I'm running the LCD4BitExample PDE that came with the library:
//example use of LCD4Bit library
#include <LCD4Bit.h>
//create object to control an LCD.
//number of lines in display=1
LCD4Bit lcd = LCD4Bit(1);
//some messages to display on the LCD
char msgs[6][15] = {"apple", "banana", "pineapple", "mango", "watermelon", "pear"};
int NUM_MSGS = 6;
void setup() {
pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat
lcd.init();
//optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
//lcd.commandWrite(0x0F);//cursor on, display on, blink on. (nasty!)
}
void loop() {
digitalWrite(13, HIGH); //light the debug LED
//pick a random message from the array
int pick = random(NUM_MSGS);
char* msg = msgs[pick];
lcd.clear();
lcd.printIn(msg);
delay(1000);
digitalWrite(13, LOW);
//print some dots individually
for (int i=0; i<3; i++){
lcd.print('.');
delay(100);
}
//print something on the display's second line.
//uncomment this if your display HAS two lines!
/*
lcd.cursorTo(2, 0); //line=2, x=0.
lcd.printIn("Score: 6/7");
delay(1000);
*/
//scroll entire display 20 chars to left, delaying 50ms each inc
lcd.leftScroll(20, 50);
}
I tried other modified versions of the LCD4Bit library for 4x20 LCDs as well as the original (using just 2 lines) but to no avail. For some of them the clear() function didn't even work.
Does anyone know why this might be happening? any help is greatly appreciated. R/W is tied to ground, pin 4 of the LCD is connected to pin 12 of the arduino and pin 6 is connected to pin 2.
Nir