Has anyone successfully added new characters to their display? I'd like an "up arrow" and a "down arrow."
Usually, these displays support custom defined characters on positions 0-7. It is just bitmap. I'm using LCD library from F. Malpartida for the years. This lib contains ::createChar() function. It's easy with this.
What is the problem specifically?
Dr_Quark:
Has anyone successfully added new characters to their display? I'd like an "up arrow" and a "down arrow."
If your display is a standard "HD44780 compatible" type that works with LiquidCrystal.h, then yes you can create your own custom characters.
Here's a piece of code from one of my sketches where I add the "degrees" symbol to display temperature (assuming you have already initialized the LCD and call it's object "LCD":
const uint8_t deg_sign[] = {
0b00110,
0b01001,
0b01001,
0b00110,
0b00000,
0b00000,
0b00000,
0b00000,
};
LCD.createChar (1, deg_sign);
The createChar function takes two parameters: The first is which character to use to print the degrees sign (0x01 in my example). The second one is the array of bits to make up the character.
To print using that character, I do this:
LCD.print ("Temperature is ");
LCD.print (temperature);
LCD.print ((char) 0x01);
LCD.print ("C");
// resulting in "Temperature is nnnĀ°C"
The LCD digits are a 5 by 8 pixel array, with the last (bottom) defining an underline. A zero is "pixel off" and a one is "pixel on".
The array for the number three would look like this:
[tt][b]# # # # # -> 1 1 1 1 1 -> 0b11111,
. . . # . -> 0 0 0 1 0 -> 0b00010,
. . # . . -> 0 0 1 0 0 -> 0b00100,
. . . # . -> 0 0 0 1 0 -> 0b00010,
. . . . # -> 0 0 0 0 1 -> 0b00001,
# . . . # -> 1 0 0 0 1 -> 0b10001,
. # # # . -> 0 1 1 1 0 -> 0b01110,
. . . . .[/b]
** -> 0 0 0 0 0 -> 0b00000,**
[/tt]
In fact, I create my characters like that (using # for 1 and . for 0, with double spacing to visualize it better, then edit the "#" to 1 and "." to zero and remove the spaces).
Lastly, if ANY bit of the bottom row is set to 1, then the entire bottom line is active, creating an underline.
Hope this helps.
Thanks. I had read the HD44780 spec sheet, but I just never got my code to work. That was a year ago. Now that I'm revamping my device I thought I'd take another shot at it.
I'm assuming that the createChar() function is in the LCD library.
"...assuming you have already initialized the LCD and call it's object "LCD" "
the idea of class and object is not familiar to me. I'll have to delve into this.
(BTW, thanks to whoever moved this to the correct topic area)
Dr_Quark:
Thanks. I had read the HD44780 spec sheet, but I just never got my code to work. That was a year ago. Now that I'm revamping my device I thought I'd take another shot at it.I'm assuming that the createChar() function is in the LCD library. <---YES it is.
Dr_Quark:
"...assuming you have already initialized the LCD and call it's object "LCD" "the idea of class and object is not familiar to me. I'll have to delve into this.
(BTW, thanks to whoever moved this to the correct topic area)
To use the LCD, you connect it to the Arduino (keep track of which ARDUINO pins are connect to which LCD pins such as Enable, D0, D1, D2, D3, etc....)
Example (of course, you need to change the #defines for the LCD pin numbers to match YOUR wiring setup):
// LCD parallel pin connections
#define _RW 38
#define _EN 39
#define _V0 40
#define _RS 41
#define _D7 42
#define _D6 43
#define _D5 44
#define _D4 45
#define _D3 46
#define _D2 47
#define _D1 48
#define _D0 49
#include <LiquidCrystal.h> // include the LCD library
static LiquidCrystal LCD (_RS, _RW, _EN, _D0, _D1, _D2, _D3); // create an LCD "object" (4 bit mode)
void setup (void)
{
LCD.begin (20, 4); // initialize a 20 character, 4 row LCD
LCD.print ("Yippee it works!");
}
void loop (void)
{
// nothing
}
This should be all you have to do......