Hello I really don't understand why my array is not working ! So I realy need your help
I searched 5 times in Google and it's showing no good results ![]()
To share with you the pictures and video I use Drop-box Download it here : https://db.tt/ji1dOCWb
So let's go ! :
I would like to do this .
Click here to see 3 steps of the displayed battery (there are 9 in total) :
I have created a 2Dimmensionnal array (see my full code below) (aka matrix) and each row contain one state of a battery here is a schematic :
row [0] : "▯▢▢▷" // this row represents an empty AAA battery
row [1] : "▮▩▢▷"
row [2] : "▮▩▩▷"
row [3] : "▮▩▩ ▶" // this row represents an Full AAA battery  :open_mouth:
and each "â–©" character is a custom made character with this function :
lcd.createChar(0, customLcdfont_squareONE);
As you saw in my video it works at the end !
but it's absolutly not the way I want it to work !
the code that works is a mess ! a shame !
I think the problem is that the Raw n°1 ([0]) starts with a 0,
(try it out it's very strange), if we replace
"char batteryFonts [10][5]={
{ 0, 1, 1, 2 }, // you see { "0"<= this, 1, 1, 2 }, is a problem I think
{ 3, 1, 1, 2 },
etc,
etc,...
// this sentence behind does not work !!! but only with the raw [0]
lcd.print( batteryFonts[0]);Â
}
with
"char batteryFonts [10][5]={
{ 4, 1, 1, 2 }, // 4 or what ever you want
etc,
etc,...
// this sentence behind does work !!! but only with a row that starts not with a 0 WHY ??? CAN U TELL ME ? please ?
lcd.print( batteryFonts[0]);Â
}
It works ! it displays right ! ![]()
Here is my full code get it and Just connect the pins 12, 13, 7, 4, 3, 2 to the LCD : and have a fun try ![]()
//This is a simple program that charges alkaline batteries
//Copyleft
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 13, 7, 4, 3, 2); // why pin 13 and not 12 ? because I love the led attached to it <3
// the empty battery - end
byte customLcdfont_A [8] = { // B stand for "Binary" and then the pixel ...
B01111,
B11000,
B10101,
B10100,
B10100,
B10100,
B11000,
B01111
// the empty battery body with fancy graphics enabled
};
byte customLcdfont_B [8] = { // B stand for "Binary" and then the pixel ...
B11111,
B00000,
B11001,
B00000,
B000000000000000000,
B00000,
B00000,
B11111
};
// the empty battery + end
byte customLcdfont_C [8] = { // B stand for "Binary" and then the pixel ...
B11100,
B00100,
B10111,
B00101, //Iloveyourmothersomutch
B00111,
B00111,
B00100,
B11100
};
// the full battery - end
byte customLcdfont_D [8] = { // B stand for "Binary" and then the pixel ...
B1111,
B11111,
B10110,
B10111,
B10111,
B10111,
B11111,
B1111
};
// the FULL battery + end
byte customLcdfont_E [8] = { // B stand for "Binary" and then the pixel ...
B11100,
B11100,
B01111,
B11101,
B11111,
B11111,
B11100,
B11100
};
// the full battery body
byte customLcdfont_F [8] = {
B11111,
B11111,
B00110,
B11111,
B11111,
B11111,
B11111,
B11111
};
// the 1/3 battery body
byte customLcdfont_G [8] = {
B11111,
B11000,
B00001,
B11000,
B11000,
B11000,
B11000,
B11111
};
// the 2/3 battery body
byte customLcdfont_H [8] = {
B11111,
B11110,
B00111,
B11110,
B11110,
B11110,
B11110,
B11111
};
/**************************************************************************/
void setup() {
 int i = 0 ;
 // initialize serial communications at 9600 bps:
 lcd.createChar(0, customLcdfont_A);
 lcd.createChar(1, customLcdfont_B);
 lcd.createChar(2, customLcdfont_C);
 lcd.createChar(3, customLcdfont_D);
 lcd.createChar(4, customLcdfont_E);
 lcd.createChar(5, customLcdfont_F);
 lcd.createChar(6, customLcdfont_G);
 lcd.createChar(7, customLcdfont_H);
 lcd.begin(16, 2);
// HELLO HERE IS THE PROBLEM !!!!
//the char table behin creates my diferent battery states as shown in the video ;)
char batteryFonts [10][5]={
{ 0, 1, 1, 2 }, // this is an empty one f%*# this does not work !!!
{ 3, 1, 1, 2 },
{ 3, 6, 1, 2 },
{ 3, 7, 1, 2 },// this is a 50 % full charged battery !
{ 3, 5, 1, 2 },
{ 3, 5, 6, 2 },
{ 3, 5, 7, 2 },
{ 3, 5, 5, 2 },
{ 3, 5, 5, 4 },// this is nice full oneÂ
};
// this sentence behind does not work !!! but only with the raw [0]
lcd.print( batteryFonts[0]);Â Â // I F***ing want this to display the first raw !!!!
lcd.setCursor(0,1 );
 lcd.print(" not working ");
lcd.setCursor(0,0 );
Â
    delay(9300); // this make a short pause for us so that we can see the result
lcd.setCursor(0,1 );
 lcd.print("  working   ");
lcd.setCursor(0,0 );
   for (i=0; i=10 ; i+=1 ){
   delay(300);
 lcd.setCursor(6,0 );
 lcd.write(byte(0)); lcd.write(byte(1)); lcd.write(byte(1)); lcd.write(byte(2));
  delay(700); // batterry 0/8 empty aka discharged
 lcd.setCursor(6,0 );
 lcd.write(byte(3)); lcd.write(byte(1)); lcd.write(byte(1)); lcd.write(byte(2));
  delay(1000); //batterry 1 /8
 lcd.setCursor(6,0 );
 lcd.write(byte(3)); lcd.write(byte(6)); lcd.write(byte(1)); lcd.write(byte(2));
 delay(1000);//batterry 2 /8
 lcd.setCursor(6,0 );
 lcd.write(byte(3)); lcd.write(byte(7)); lcd.write(byte(1)); lcd.write(byte(2)); //batery 3 /8
 delay(1000);
 lcd.setCursor(6,0 );
 lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(1)); lcd.write(byte(2));
 delay(1000); //batery 4 /8
 lcd.setCursor(6,0 );
    lcd.write(byte(3)); lcd.write(byte(5));  lcd.write(byte(6)); lcd.write(byte(2));
 delay(1000); //batery 5 /8
 lcd.setCursor(6,0 );
   lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(7)); lcd.write(byte(2));
    delay(1000); //batery 6 /8
 lcd.setCursor(6,0 );
   lcd.write(byte(3)); lcd.write(byte(5)); lcd.write(byte(5)); lcd.write(byte(2));
   delay(1000); //batery 7 /8
 lcd.setCursor(6,0 );
  lcd.write(byte(3)); lcd.write(byte(5));  lcd.write(byte(5));  lcd.write(byte(4)); //batery 8 /8
  delay(1000);
   }
  lcd.setCursor(15, 1);
  delay(115000);
}
/**************************************************************************/
void loop() {
//This is not interesting here
 lcd.print(" ~ The end of the code ... thank you for reading ;) ~ ");
}
Good luck ! (you can try the code above it compiles
???