Go Down

Topic: [SOLVED] How to createChar with items inside an array (Read 1 time) previous topic - next topic


Nov 24, 2012, 02:47 am Last Edit: Nov 24, 2012, 04:02 am by ArOnBaldo Reason: 1
Please, i've looked around the forum but no found solution to my problem, someone can help me to create the character with items inside an array.

"a" is 1 to 16 and I want to build a character (5x8) within the array "alines" in position "a" to "+7".

thank you

Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 9, 8, 7, 6, 5, 4, 3, 2);
byte alines[ ] = {
 B10000, B11000, B10100, B10010, B10001, B10000,
 B11000, B11111, B11010, B11001, B11000, B11000,
 B11100, B11010, B11001, B11111, B11111, B11101,
 B11100, B11100, B11100, B11110, B11101,};
long a = 0;
void setup()
 lcd.begin(16, 2);
void loop()
 lcd.createChar(1, a to a +7); /// NEED CREATECHEAR with 8 BYTEs of "alines" from A to A + 7
 lcd.setCursor(0, 0);
 a = a + 1;
 if ( a > 17 ) { a = 1 ;}



lcd.createChar(num, data)
num: which character to create (0 to 7)
data: the character's pixel data

"each custom character is specified by an array of eight bytes, one for each row."

To specify the 8 bytes starting at index 'a' use:

Code: [Select]
lcd.createChar(1, &alines[a]);

Don't worry about the "a+7".  The createChar() function knows how to count to 7.

You can also write it this way:
Code: [Select]
lcd.createChar(1, alines+a);
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

Go Up