custom characters on lcd screen

I use custom characters that I created with this handy tool: http://icontexto.com/charactercreator/
But I have some strange problems...
Sometimes characters do not write correct.
This is a simple example.
This code should show an small "v" for volt and a small "H" on an lcd screen.
But it shows "HH".
I clearly write character 3 and 11, but writes 11 twice.
This is not the first problem, and can solve it with renaming some numbers, but verry unpredictable.
When I change number 11 to 15, it does show an "vh" correctly, why?
Whats the problem here?

#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4, 7, 12, 13); // LCD Display I/O

byte volt[8] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B10100,
B10100,
B01000
};

byte high[8] = {
B00000,
B00000,
B00000,
B10100,
B10100,
B11100,
B10100,
B10100
};

void setup ()
{
lcd.begin(16, 2);
lcd.createChar(3, volt);
lcd.createChar(11, high);
}

void loop (){
lcd.setCursor (0, 0);
lcd.write(3);
lcd.write(11);
}

LiquidCrystal wants a number from 0-7. You can only have 8 glyphs at a time. 15 should not be working, though...

baum, you beat me to it.

OP, how many custom characters did you think the display has? Why do you need custom characters v and H that are already in the character set?

They look to be smaller than the standard font size.

I'm not sure how lcd.createChar deals with the numbers above 7 but the controller treats 8-F as foldback addresses. Those values get you to the same memory locations as 0-7.

Don

I see, it works good as long when I use 0-7.
Higher values replace one of those 7 characters.
7byte of memory isn't much, I wanted to use around 15.
Is there a list of all standard characters on the lcd's?

Not sure what LCD chipset you have but this one is fairly common: (all sparkfun models have it)

page 17+18 have the characters.

baum

Thanks for the pdf.
But when I want to print for example an "arrow up" from page 18, how do I do that?

I'm not sure... Liquid crystal only has support for ASCII. Any body know how to print the other characters? page 18 is filled with over 100 special characters that could save some space instead of having to create our own...

baum

Which ROM do you have?

ROM code A02 up-arrow looks to me to be 0x18

Liquid crystal only has support for ASCII.

I'm no C programmer but the information about lcd.print here LiquidCrystal - Arduino Reference does not support your statement. To print any of the characters on the chart you must first determine the binary character code. You get the upper four bits from the column headings and the lower four bits from the row headings. For example for the capital "Sigma" symbol the column heading is 1001 and the row heading is xxxx0100. You substitute the values from the column heading for the 'xxxx' part of the row heading and you get 10010100. This is your 'data' and the 'BASE' should be BIN. So to print a Sigma you would use

lcd.print(10010100, BIN);

.

Don

So to print a Sigma you would use lcd.print(10010100, BIN);.

0x94, maybe, but not 10010100, which would be a lowercase 'o' with circumflex (I think)

But how would you specify which rom to use?

But how would you specify which rom to use?

You have to ask the manufacturer when they supply the driver chip

Oh! So his LCD has one or the other. In that case, it is easier than I though it was... Sorry!

AWOL:

So to print a Sigma you would use lcd.print(10010100, BIN);.

0x94, maybe, but not 10010100, which would be a lowercase 'o' with circumflex (I think)

What's the difference between using 94 hex and 10010100 binary?

The lowercase 'o' with circumflex is 11010100 binary or D4 hex.

This is a prime example of using the appropriate radix. The original information was provided in binary so that is the appropriate radix to use. When you convert to another radix, such as hex, the very best you can do is get it right.

Don

What's the difference between using 94 hex and 10010100 binary?

No difference at all, but you wrote 10010100 in decimal, which is 0x98BDF4
0xf4 in the character ROM is a lowercase 'o' with circumflex (0xD4 is uppercase)

When you convert to another radix, such as hex, the very best you can do is get it right.

Can't disagree there.

No difference at all, but you wrote 10010100 in decimal,

Do you mean here ... "you would use

lcd.print(10010100, BIN);

" ? As i said, I am no C programmer but I assumed that specifying a base of BIN would cause the number 10010100 to be interpreted as binary.

Don

I assumed that specifying a base of BIN would cause the number 10010100 to be interpreted as binary.

That's not how the C compiler works - it sees 10010100 as 0x98BDF4 and that's the end of it.

Some flavours of C allow you to write 0b10010100, and the Arduino has B10010100 (but that's just a macro).

It becomes interesting had you written, say, 010010100, in which case the compiler would have interpreted this as 2101312 decimal or 0x201040.

Programming is all about detail, not assumptions.

From what you are saying it looks like the term BASE refers to the output, not the input. So what would the correct syntax be now that we agree on the value to use? Would these work?

lcd.print(0b10010100);

lcd.print(0x94);

Don