Skip to main content
change typing mistakes
Source Link

I have created a 2D array (see my full code below), and each row contaisncontains one state of a battery here is a schematic :

I have created a 2D array (see my full code below), and each row contaisn one state of a battery here is a schematic :

I have created a 2D array (see my full code below), and each row contains one state of a battery here is a schematic :

deleted 224 characters in body; edited tags
Source Link

I searched on Google, youtube and even on the darknet (joke)

I have created a 2 D2D array (see my full code below), and each row containcontaisn 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

row [0] : "▯▢▢▷" // this row represents an empty AAA battery 
row [1] : "▮▩▢▷"
row [2] : "▮▩▩▷"
row [3] : "▮▩▩ ▶"  // this row represents a Full AAA battery    

and eachEach "▩" character is a custom made character with this function  :

lcd.createChar(0, customLcdfont_squareONE);

lcd.createChar(0, customLcdfont_squareONE);

As you saw in my video it works at the end ! but, but it's absolutlyabsolutely not the way I want it to work ! the. 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. If we replace

char batteryFonts [10][5]=[10][5] = {
  { 0, 1, 1, 2 }, // you see { this "0", 1, 1, 2 }, is a problem I think 
  { 3, 1, 1, 2 },
  {etc}, }
lcd.print( batteryFonts[0]);  // this sentence  does not work !!! 
"char batteryFonts [10][5]={{ 4, 1, 1, 2 }, // 4 or what ever you want 
  {etc}, 
  {etc}, }
 
 lcd.print( batteryFonts[0]);  // this sentence behind does  work !!!, but only with a row that startsdoes not start with a 0 WHY ??? can u tell me please. Why? 

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 Have a fun try ;).

Good luck ! (you can try the code above it compiles

I searched on Google, youtube and even on the darknet (joke)

I have created a 2 D array (see my full code below) 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

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 { this "0", 1, 1, 2 }, is a problem I think 
{ 3, 1, 1, 2 },
{etc}, }
lcd.print( batteryFonts[0]);  // this sentence  does not work !!! 
"char batteryFonts [10][5]={{ 4, 1, 1, 2 }, // 4 or what ever you want 
{etc}, 
{etc}, }
 
 lcd.print( batteryFonts[0]);  // this sentence behind does  work !!! but only with a row that starts not with a 0 WHY ??? can u tell me please ? 

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 Have a fun try ;)

Good luck ! (you can try the code above it compiles

I have created a 2D array (see my full code below), and each row contaisn 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 a Full AAA battery    

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 absolutely not the way I want it to work. The code that works is a mess!

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 { this "0", 1, 1, 2 }, is a problem I think 
  { 3, 1, 1, 2 },
  {etc}, }
lcd.print( batteryFonts[0]);  // this sentence does not work
"char batteryFonts [10][5]={{ 4, 1, 1, 2 }, // 4 or what ever you want 
  {etc}, 
  {etc}, }
 lcd.print( batteryFonts[0]);  // this sentence behind does work, but only with a row that does not start with a 0. Why?

It works!

Here is my full code. Just connect the pins 12, 13, 7, 4, 3, 2 to the LCD.

Source Link

lcd.print and 2D arrays

I searched on Google, youtube and even on the darknet (joke)

Click here to see my program running

I have created a 2 D array (see my full code below) 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

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 { this "0", 1, 1, 2 }, is a problem I think 
{ 3, 1, 1, 2 },
{etc}, }
lcd.print( batteryFonts[0]);  // this sentence  does not work !!! 

with

"char batteryFonts [10][5]={{ 4, 1, 1, 2 }, // 4 or what ever you want 
{etc}, 
{etc}, }

 lcd.print( batteryFonts[0]);  // this sentence behind does  work !!! but only with a row that starts not with a 0 WHY ??? can u tell me please ? 

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 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,
B00000,
B00000,
B00000,
B11111
};


// the empty battery + end

byte customLcdfont_C [8] = { // B stand for "Binary" and then the pixel ... 
B11100,
B00100,
B10111,
B00101, 
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); 

// WATCH HERE IS THE PROBLEM !!!!

//the char table behind creates my different 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