Big Numbers in Arabic font

As I'd like to add Arabic Numbers to my LCD I2C project, I followed the instructions in this tutorials.

and here is code provided by the Author on GIThub

LCD_Big_digits/LCD_CustChar_Demo_2_With_Serial_Window_Stepthru/LCD_CustChar_Demo_2_With_Serial_Window_Stepthru.ino at master · RalphBacon/LCD_Big_digits (github.com)

And here is my version, All What I did is changed the sequence of the second array to display Arabic numbers instead of the English numbers.

#include <Adafruit_LiquidCrystal.h>
#include <Keypad.h>

const int ROW_NUM    = 4; // four rows
const int COLUMN_NUM = 4; // four columns

char keys[ROW_NUM][COLUMN_NUM] = {
  {'1','2','3', 'A'},
  {'4','5','6', 'B'},
  {'7','8','9', 'C'},
  {'*','0','#', 'D'}
};

byte pin_rows[ROW_NUM] = {9, 8, 7, 6};      // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // connect to the column pinouts of the keypad

Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

Adafruit_LiquidCrystal lcd_1(0);

uint8_t custChar[8][8] = {
  {31, 31, 31, 0, 0, 0, 0, 0},      // Small top line - 0
  {0, 0, 0, 0, 0, 31, 31, 31},      // Small bottom line - 1
  { B11111,
    B00000,
    B00000,
    B00000,                         // This shows an alternative
    B00000,                         // way of defining a custome character,
    B00000,                         // a bit more 'visually' perhaps?
    B00000,
    B11111,
  },
  //{31, 0, 0, 0, 0, 0, 0, 31},     // Small lines top and bottom -2
  {0, 0, 0, 0, 0, 0,  0, 31},       // Thin bottom line - 3
  {31, 31, 31, 31, 31, 31, 15, 7},  // Left bottom chamfer full - 4
  {28, 30, 31, 31, 31, 31, 31, 31}, // Right top chamfer full -5
  {31, 31, 31, 31, 31, 31, 30, 28}, // Right bottom chamfer full -6
  {7, 15, 31, 31, 31, 31, 31, 31},  // Left top chamfer full -7
};

// Define our numbers 0 thru 9
// 254 is blank and 255 is the "Full Block"
uint8_t bigNums[10][6] = {
  {1, 254, 254, 0, 254, 254},         //0
  {254, 255, 254, 254, 255, 254},     //1
  {255, 0, 0, 255, 254, 254},         //2
  {255, 3, 255, 255, 254, 254},         //3
  {7, 2, 0, 5, 3, 1}, //4
  {254, 1, 254, 4, 1, 6},         //5
  {0, 0, 5, 254, 254,255},         //6
  {255, 254, 255, 4, 1, 6},   //7
  {7, 0, 5, 255, 254, 255},         //8
  {255, 2, 5, 255, 254, 254},         //9
};


void setup() {
  // Initiate the LCD:
  lcd_1.begin(16,2);
}  
 
int cursorColumn = 0;

void printBigNum(int number, int startCol, int startRow) {

  // Position cursor to requested position (each char takes 3 cols plus a space col)
  lcd_1.setCursor(startCol, startRow);

  // Each number split over two lines, 3 chars per line. Retrieve character
  // from the main array to make working with it here a bit easier.
  uint8_t thisNumber[6];
  for (int cnt = 0; cnt < 6; cnt++) {
    thisNumber[cnt] = bigNums[number][cnt];
  }

  // First line (top half) of digit
  for (int cnt = 0; cnt < 3; cnt++) {
    lcd_1.print((char)thisNumber[cnt]);
  }

  // Now position cursor to next line at same start column for digit
  lcd_1.setCursor(startCol, startRow + 1);

  // 2nd line (bottom half)
  for (int cnt = 3; cnt < 6; cnt++) {
    lcd_1.print((char)thisNumber[cnt]);
  }
}

void loop(){
  char key = keypad.getKey();
 
  if (key) {
    lcd_1.setCursor(cursorColumn,0); // move cursor to   (cursorColumn, 0)
    //lcd_1.print(key);                 // print key at (cursorColumn, 0)
    
    printBigNum(key, cursorColumn, 0);

    
    cursorColumn+=4;                 // move cursor to next position
    if(cursorColumn > 16) {        // if reaching limit, clear LCD
      lcd_1.clear();
      cursorColumn = 0;
    }
  }
  
}

And here is the link to the simulation on tinkercad

it seems that my code works partially except for not being able to display the supposed Characters?
What is the possible fix for that.

I moved your topic to an appropriate forum category @drmina2023.

I have had to do this with your topics multiple times. It seems that polite requests for you to use the forum responsibly are not sufficient so I have given you a two day suspension. Upon your return, I hope that you will start behaving more respectfully.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

It seems the link doesn't work anymore (the project has been deleted?)...

You defined the array of custom character data, but I don't see anywhere that you actually send the custom character data to the display.

@drmina2023
See if the code below meets your needs.
The library can be found in the link placed after #include;

How it works can be seen in the simulator:

#include <LiquidCrystal.h>
#include <BigNumbers.h>   // https://github.com/seanauff/BigNumbers/tree/master
//#include "BigNumbers.h"     // https://github.com/seanauff/BigNumbers/tree/master 
const int lcdD7Pin = 10; // LCD D7 pin
const int lcdD6Pin = 11; // LCD D6 pin
const int lcdD5Pin = 12; // LCD D5 pin
const int lcdD4Pin = 13; // LCD D4 pin
const int lcdEPin = 14; // LCD E Pin
const int lcdRSPin = 15; // LCD RS pin
LiquidCrystal lcd(lcdRSPin, lcdEPin, lcdD4Pin, lcdD5Pin, lcdD6Pin, lcdD7Pin);
BigNumbers bigNum(&lcd);

#include <Keypad.h>
const int ROW_NUM    = 4; // four rows
const int COLUMN_NUM = 4; // four columns
char keys[ROW_NUM][COLUMN_NUM] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte pin_rows[ROW_NUM] = {9, 8, 7, 6};      // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

int count = 0;
long acc = 0;
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  lcd.begin(16, 2);
  bigNum.begin(); // set up BigNumbers
  lcd.clear(); // clear display
}
//------------------------------------------------------------------------------
void loop() {
  long key = keypad.getKey();
  if (key) {
    long convKey;
    if (key >= 30 or key <= 39)
    {
      convKey = key & 0x0F;
      acc = acc + convKey;
      bigNum.displayLargeInt(acc, 0, 5, false);
      acc = acc * 10;
      count++;
      if(count > 5)
      {
        lcd.clear(); // clear display
        count = 0;
        acc = 0;
      }
    }
  }
}

@docdoc
here is a new link

@david_2018 Sorry for my late answer but can't you help me to modify the code to do that, especially the original tutorial works extremely well in the video above .

@ruilviana
I knew this library, but I'd like to display Arabic big Numbers, so the first code suits me better.
I hope you can tinker it on Tinker cad to check its problem.
here is the Link

Shouldn't that be
if (key >= 0x30 or key <= 0x39)
?

I'm Not really sure about that Line
But Should you check this copy of Wokwi

I tinkered it , but still has some glitches.

You forgot your break; for your case 3: and your case 7: for those two digits.

Exactly, this why those 2 numbers were faulty, that's great.
The point now how to download only the aabic library from the rest of the project

I don't have the hardware to test with the Adafruit library, but the major problem with your original code is that you never sent the custom character data to the LCD display. If the remainder of the code is correct, this should work:

void setup() {
  // Initiate the LCD:
  lcd_1.begin(16, 2);
  for (byte i = 0; i < sizeof(custChar) / sizeof(custChar[0]); i++) {
    lcd_1.createChar(i, custChar[i]);
  }
}

Nope.
image

Please either link to a project you don't delete, or switch to Wokwi.

I never used a library, just check this out, it's a portion of a project I made some time ago:

Test.ino:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include "LargeNumbers.h"

int secs = 0;

void setup()
{
  Serial.begin(115200);	// Debugging only
  initLcd();
 }

void loop()
{
  printValue(4, 4, secs++); 
  delay(1000);
}

LargeNumbers.h:

// the 8 arrays that form each segment of the custom numbers
byte bar1[8] = 
{
        B11100,
        B11110,
        B11110,
        B11110,
        B11110,
        B11110,
        B11110,
        B11100
};
byte bar2[8] =
{
        B00111,
        B01111,
        B01111,
        B01111,
        B01111,
        B01111,
        B01111,
        B00111
};
byte bar3[8] =
{
        B11111,
        B11111,
        B00000,
        B00000,
        B00000,
        B00000,
        B11111,
        B11111
};
byte bar4[8] =
{
        B11110,
        B11100,
        B00000,
        B00000,
        B00000,
        B00000,
        B11000,
        B11100
};
byte bar5[8] =
{
        B01111,
        B00111,
        B00000,
        B00000,
        B00000,
        B00000,
        B00011,
        B00111
};
byte bar6[8] =
{
        B00000,
        B00000,
        B00000,
        B00000,
        B00000,
        B00000,
        B11111,
        B11111
};
byte bar7[8] =
{
        B00000,
        B00000,
        B00000,
        B00000,
        B00000,
        B00000,
        B00111,
        B01111
};
byte bar8[8] =
{
        B11111,
        B11111,
        B00000,
        B00000,
        B00000,
        B00000,
        B00000,
        B00000
};

void initLcd() {
  lcd.init();
  lcd.backlight();

  lcd.createChar(1,bar1);
  lcd.createChar(2,bar2);
  lcd.createChar(3,bar3);
  lcd.createChar(4,bar4);
  lcd.createChar(5,bar5);
  lcd.createChar(6,bar6);
  lcd.createChar(7,bar7);
  lcd.createChar(8,bar8);
}

// digits 0 to 9, and 10 is a space
byte custom[11][6] = {
  {2,8,1,2,6,1},      // 0
  {32,32,1,32,32,1},  // 1
  {5,3,1,2,6,6},      // 2
  {5,3,1,7,6,1},      // 3
  {2,6,1,32,32,1},    // 4
  {2,3,4,7,6,1},      // 5
  {2,3,4,2,6,1},      // 6
  {2,8,1,32,32,1},    // 7
  {2,3,1,2,6,1},      // 8
  {2,3,1,7,6,1},      // 9
  {32,32,32,32,32,32} // space
};

void printChar(char value, byte col) {
  int i = value - '0';
  if ( value == ' ' ) i = 10;
  lcd.setCursor(col, 0);
  for (int j=0; j<=5; ++j) {
    if ( j == 3 ) lcd.setCursor(col, 1); 
    lcd.write(custom[i][j]);
  }
}  

void printDot(byte col) {
  lcd.setCursor(col, 0);
  lcd.write(' ');
  lcd.setCursor(col, 1); 
  lcd.write('.');
}

char buf[6];

// Display the integer value with spaces
void printValue(byte col, int size, int v) {
  if (size > 5) size = 5;
  sprintf(buf, "%5d", v);
  for(byte c=5-size; c<=size; ++c) {
    printChar(buf[c], col);
    col += 3;
  }
}

// Display the integer value with zero padding
void printValueZ(byte col, int size, int v) {
  if (size > 5) size = 5;
  sprintf(buf, "%05d", v);
  for(byte c=5-size; c<=size; ++c) {
    printChar(buf[c], col);
    col += 3;
  }
}

Here is the test sketch on Wokwi:

@docdoc
@david_2018

Here is the new Link

As I'm Beginner I can't Use Wokwi now.
And here is the final code where I added Creatchar function

#include <Adafruit_LiquidCrystal.h>
#include <Keypad.h>

const int ROW_NUM    = 4; // four rows
const int COLUMN_NUM = 4; // four columns

char keys[ROW_NUM][COLUMN_NUM] = {
  {'1','2','3', 'A'},
  {'4','5','6', 'B'},
  {'7','8','9', 'C'},
  {'*','0','#', 'D'}
};

byte pin_rows[ROW_NUM] = {9, 8, 7, 6};      // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // connect to the column pinouts of the keypad

Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

Adafruit_LiquidCrystal lcd_1(0);

uint8_t custChar[8][8] = {
  {31, 31, 31, 0, 0, 0, 0, 0},      // Small top line - 0
  {0, 0, 0, 0, 0, 31, 31, 31},      // Small bottom line - 1
  { B11111,
    B00000,
    B00000,
    B00000,                         // This shows an alternative
    B00000,                         // way of defining a custome character,
    B00000,                         // a bit more 'visually' perhaps?
    B00000,
    B11111,
  },
  //{31, 0, 0, 0, 0, 0, 0, 31},     // Small lines top and bottom -2
  {0, 0, 0, 0, 0, 0,  0, 31},       // Thin bottom line - 3
  {31, 31, 31, 31, 31, 31, 15, 7},  // Left bottom chamfer full - 4
  {28, 30, 31, 31, 31, 31, 31, 31}, // Right top chamfer full -5
  {31, 31, 31, 31, 31, 31, 30, 28}, // Right bottom chamfer full -6
  {7, 15, 31, 31, 31, 31, 31, 31},  // Left top chamfer full -7
};

// Define our numbers 0 thru 9
// 254 is blank and 255 is the "Full Block"
/*uint8_t bigNums[10][6] = {
  {1, 254, 254, 0, 254, 254},         //0
  {254, 255, 254, 254, 255, 254},     //1
  {255, 0, 0, 255, 254, 254},         //2
  {255, 3, 255, 255, 254, 254},         //3
  {7, 2, 0, 5, 3, 1}, //4
  {254, 1, 254, 4, 1, 6},         //5
  {0, 0, 5, 254, 254,255},         //6
  {255, 254, 255, 4, 1, 6},   //7
  {7, 0, 5, 255, 254, 255},         //8
  {255, 2, 5, 255, 254, 254},         //9
};*/

uint8_t bigNums[10][6] = {
  {7, 0, 5, 4, 1, 6},         //0
  {0, 5, 254, 1, 255, 1},     //1
  {0, 2, 5, 7, 3, 1},         //2
  {0, 2, 5, 1, 3, 6},         //3
  {7, 3, 255, 254, 254, 255}, //4
  {7, 2, 0, 1, 3, 6},         //5
  {7, 2, 0, 4, 3, 6},         //6
  {0, 0, 5, 254, 7, 254},   //7
  {7, 2, 5, 4, 3, 6},         //8
  {7, 2, 5, 1, 3, 6},         //9
};


void setup() {
  // Initiate the LCD:
  lcd_1.begin(16,2);
  
   // Create custom character map (8 characters only!)
 for (int cnt = 0; cnt < sizeof(custChar) / 8; cnt++) {
    lcd_1.createChar(cnt, custChar[cnt]);
  }

}
 
int cursorColumn = 0;

void printBigNum(int number, int startCol, int startRow) {

  // Position cursor to requested position (each char takes 3 cols plus a space col)
  lcd_1.setCursor(startCol, startRow);

  // Each number split over two lines, 3 chars per line. Retrieve character
  // from the main array to make working with it here a bit easier.
  uint8_t thisNumber[6];
  for (int cnt = 0; cnt < 6; cnt++) {
    thisNumber[cnt] = bigNums[number][cnt];
  }

  // First line (top half) of digit
  for (int cnt = 0; cnt < 3; cnt++) {
    lcd_1.print((char)thisNumber[cnt]);
  }

  // Now position cursor to next line at same start column for digit
  lcd_1.setCursor(startCol, startRow + 1);

  // 2nd line (bottom half)
  for (int cnt = 3; cnt < 6; cnt++) {
    lcd_1.print((char)thisNumber[cnt]);
  }
}
  
void loop(){
  char key = keypad.getKey();
  int cursorColumn = 0;
 
  if (key) {
    lcd_1.setCursor(cursorColumn,0); // move cursor to   (cursorColumn, 0)
    //lcd_1.print(key);                 // print key at (cursorColumn, 0)
    
    printBigNum(key, cursorColumn, 0);

    
    cursorColumn+=4;                 // move cursor to next position
    if(cursorColumn > 16) {        // if reaching
 limit, clear LCD
      lcd_1.clear();
      cursorColumn = 0;
    }
  }
}


It sort of working without a great result

Why? Wokwi isn't any hard to use, not more than Tinkercad...
Aynway, why don't you try my test code, even on Tinkercad?
Ok, this is my test code, on Tinkercad (just a couple of minutes to change the project...):

1 Like

@docdoc
I really appreciate your help ,
but please, what is the role of the following functions as I can't find any use for them.
void printValueZ
printChar
printDot
if possible could you give example using those functions .

Look at my "Largenumbers.h" I posted before, there are some comments.
For instance, printValue and printValueZ are defined as:

// Display the integer value with spaces
void printValue(byte col, int size, int v) {
...
// Display the integer value with zero padding
void printValueZ(byte col, int size, int v) {

I suppose you mean you want to know parameters usage...

  • "col" is the LCD column to start with (0-15, but as large numbers are 3 cols wide, it should go from 0 to 12)
  • "size" is the number of characters to be printed (from 1 to 5 because a 16 chars display can show up to 5 digits 3 chars wide)
  • "v" is the integer value to be printed

So a "printValue(0, 3, 80)" prints " 80" (with a leading space) at column 0 (on columns 0 to 2), while a "printValueZ(0, 3, 80)" prints "080".

"printChar" is a sub-function used by "printValue" and "printValueZ" to print a single char. Anyway you can use it to print single characters. Example, a "printChar('4', 0)" will print a large zero "4" digit at column 0.
"printDot" is a function not used here, but prints just a small dot. It will come to hand if you plan to extend the functions to print decimal dot for float values. Just as a hint, a "printValueF" to print float numbers could be something like this:

void printValueF(byte col, float v) {
  dtostrf(v, 4, 2, buf);
  for(byte c=0; c<4; ++c) {
    if ( buf[c] == '.' ) {
      printDot(col);
      ++col;
    } else {
      printChar(buf[c], col);
      col += 3;
    }
  }
}

Your code is awesome, I'm sure I can tinker it and I will give you feedback