Go Down

Topic: Custom character doesn't display on Liquid Crystal LCD. (Read 703 times) previous topic - next topic

UdvPeter

Hello!

I'm having a strange problem displaying custom characters with my arduino I tried the CustomCharacter example and it worked but when I tried to compile my this code it just didn't show anything.(note: pin 6 is connected to the contrast pin on my LCD)


Quote

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte heart[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};
void setup()
{
  analogWrite(6,0);
  lcd.begin(16,2);
}
void loop()
{
  lcd.createChar(1,0);
  lcd.createChar(1,heart);
  lcd.write(1);
  delay(1000);
}


marco_c

I would move it out of the loop and put it in setup. Even with your delay I think the screens don't like to be hammered with data (probably in the libraries). You also don't need to set the character to zero at all - just define what you need.
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

floresta

Quote
I would move it out of the loop and put it in setup.

Yes, you really should do this while you are testing things.  There is no need to 'refresh' the LCD so any information that does not change should be sent in setup. 

I suspect that you ultimately want to cycle between several custom characters which would be done in loop.  Get your code working with one character (in setup) and then move the working code to loop.

Quote
... but when I tried to compile my this code it just didn't show anything.(note: pin 6 is connected to the contrast pin on my LCD)

The contrast pin typically requires around 0.5 volts for a good display.  When you get above a volt or so the display will be blank. 

Try disconnecting the LCD contrast pin from your Arduino and temporarily connecting it to GND.  This may give you a very dark display but you should be able to ascertain whether the rest of your code is working.


Don

Docedison

FyI in the absence of a pot of any value... less than 10 Megs resistance, a 4K7 resistor from Vcc to the contrast pin (usually 3 IIRC) and a 330 ohm resistor to ground will produce a display with acceptable contrast.
Some LCD's are a little different so your mileage might vary. I've never found one much different though.

Bob
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

UdvPeter

Hello!
Many thanks for your replies.I figured out the solution this morning. I had the idea to put an
Code: [Select]
lcd.clear() after creating the character and it worked. Here's how my code looked after that:
Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte heart[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};
void setup()
{
  analogWrite(6,0);
  lcd.begin(16,2);
  lcd.createChar(1,heart);
lcd.clear();
}
void loop()
{
  lcd.write(1);
  delay(1000);
}

Go Up