Pages: [1]   Go Down
Author Topic: Custom character doesn't display on Liquid Crystal LCD.  (Read 673 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}

Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1285
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Western New York, USA
Online Online
Faraday Member
**
Karma: 40
Posts: 4400
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2927
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

--> 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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!
Many thanks for your replies.I figured out the solution this morning. I had the idea to put an
Code:
lcd.clear()
after creating the character and it worked. Here's how my code looked after that:
Code:
#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);
}
Logged

Pages: [1]   Go Up
Jump to: