Pages: [1]   Go Down
Author Topic: [SOLVED] How to createChar with items inside an array  (Read 437 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

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:


#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);
  lcd.write(1);
  delay(300);
  a = a + 1;
  if ( a > 17 ) { a = 1 ;}
}


« Last Edit: November 23, 2012, 10:02:08 pm by ArOnBaldo » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8646
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Reference/LiquidCrystalCreateChar

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:
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:
lcd.createChar(1, alines+a);
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

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

Solved.

Thanks
Logged

Pages: [1]   Go Up
Jump to: