Invalid header finle tinkercad

I have a digital scale project, and I have a good code working for it
now I would like to have Arabic characters in the lcd display so I added the following code for each Arabic letter.
the problem when adding those lines it gave me invalid header error for no reasons, as the code is working fine before adding them

lcd_1.createChar(12, Alef1);
    lcd_1.setCursor(16,0);
    lcd_1.write(12);
    
    lcd_1.createChar(13, Dal1);
    lcd_1.setCursor(15,0);
    lcd_1.write(13);
    
    lcd_1.createChar(14, Khaa3);
    lcd_1.setCursor(14,0);
    lcd_1.write(14);
    
    lcd_1.createChar(15, Laam3);
    lcd_1.setCursor(13,0);
    lcd_1.write(15);
    
    lcd_1.createChar(16, Seen3);
    lcd_1.setCursor(10,0);
    lcd_1.write(16);
     
    lcd_1.createChar(17, Noon2);
    lcd_1.setCursor(9,0); 
    lcd_1.write(17);
    
    lcd_1.createChar(18, Kaaf1);
    lcd_1.setCursor(8,0);
    lcd_1.write(18); 

here is project link on tinker cad, it works fine now as I commented lines from 366 to 393 and if you remove the comments the error appears again .

The first parameter for the createChar() function is the character number to be used and that can only be from 0 to 7

ok that is great , thank for your fast response

I tweaked the code and it worked again , but only having 7 character is a serious limitation , as I'd like add more Arabic letters.
are there any available work around .

The only partial workaround that I know of is to redefine one of the 8 user defined characters just before you use it

However, any instances of that character already on the screen will also change to show the new definition so the workaround is only useful in a small number of use cases

It is tempting to try and revise the library to accommodate more user defined characters but the number that can be used appears to be a limitation of the display hardware rather than the library

I've tried writing 2 sentences to the display , each sentence with 2 words , each word has 3 to 4 characters.

the first 1 worked fine

lcd_1.createChar(0, Alef1);
    lcd_1.setCursor(15,0);
    lcd_1.write(0);
    
    lcd_1.createChar(1, Dal1);
    lcd_1.setCursor(14,0);
    lcd_1.write(1);
    
    lcd_1.createChar(2, Khaa3);
    lcd_1.setCursor(13,0);
    lcd_1.write(2);
    
    lcd_1.createChar(3, Laam3);
    lcd_1.setCursor(12,0);
    lcd_1.write(3);
    
    lcd_1.createChar(4, Rhaa1);
    lcd_1.setCursor(10,0);
    lcd_1.write(4);
     
    lcd_1.createChar(5, Qaaf1);
    lcd_1.setCursor(9,0);
    lcd_1.write(5);
    
    lcd_1.createChar(6, Meem2);
    lcd_1.setCursor(8,0);
    lcd_1.write(6);
    
    lcd_1.createChar(7, Kaaf1);
    lcd_1.setCursor(7,0);
    lcd_1.write(7);

while the 2nd one didn't work though I adhered to 8 character set , it woks only if I I'd like to display just one word while commenting the other .

lcd_1.createChar(0, Alef1);
    lcd_1.setCursor(15,0);
    lcd_1.write(0);
    
    lcd_1.createChar(1, Dal1);
    lcd_1.setCursor(14,0);
    lcd_1.write(1);
    
    lcd_1.createChar(2, Khaa3);
    lcd_1.setCursor(13,0);
    lcd_1.write(2);
    
    lcd_1.createChar(3, Laam3);
    lcd_1.setCursor(12,0);
    lcd_1.write(3); 
  
    /*
    lcd_1.createChar(4, Seen3);
    lcd_1.setCursor(10,0);
    lcd_1.write(4);
     
    lcd_1.createChar(5, Noon2);
    lcd_1.setCursor(9,0);
    lcd_1.write(5);
    
    lcd_1.createChar(6, Kaaf1);
    lcd_1.setCursor(8,0);
    lcd_1.write(6); */

Any Solution to that.

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

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.

sure

The snippet of code that you posted looks like it should work but please post the full sketch showing how the user defined character arrays are defined

Which Arduino board are you using ?

I'm using arduino uno for simulation

here is the full sketch

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


int trigPin = 11;    // TRIG pin
int echoPin = 10;    // ECHO pin

float duration_us, distance_cm;


Adafruit_LiquidCrystal lcd_1(0);


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 customKeypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

byte Alef1[] = {
  B00100,
  B00110,
  B00110,
  B00100,
  B00100,
  B00100,
  B00100,
  B00100
};

byte Dal1[] = {
  B00000,
  B00000,
  B01100,
  B00010,
  B00001,
  B11110,
  B00000,
  B00000
};

byte Khaa3[] = {
  B00000,
  B00010,
  B11000,
  B01100,
  B00010,
  B11111,
  B00000,
  B00000
};

byte Laam3[] = {
  B00000,
  B00010,
  B00010,
  B00010,
  B00010,
  B10010,
  B11111,
  B00000
};

byte Rhaa1[] = {
  B00000,
  B00000,
  B00000,
  B00001,
  B00010,
  B00100,
  B11000,
  B00000
};

byte Qaaf1[] = {
  B01010,
  B00000,
  B00110,
  B01001,
  B01001,
  B00111,
  B00001,
  B11111
};

byte Meem2[] = {
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00110,
  B11111,
  B00110
};

byte Geem1[] = {
  B00000,
  B11100,
  B00110,
  B00011,
  B11111,
  B00000,
  B00100,
  B00000
};

byte Wao2[] = {
  B00000,
  B01100,
  B10010,
  B10010,
  B01111,
  B00100,
  B01000,
  B10000
};

byte Laam1[] = {
  B00011,
  B00011,
  B00011,
  B00011,
  B00011,
  B00011,
  B11111,
  B11111
};

byte Kaaf1[] = {
  B00001,
  B00101,
  B01001,
  B11101,
  B00001,
  B10001,
  B11111,
  B00000
};

byte Seen3[] = {
  B00000,
  B00000,
  B00000,
  B10101,
  B10101,
  B10101,
  B10101,
  B11111
};

byte Noon2[] = {
  B00000,
  B00100,
  B00100,
  B00000,
  B10010,
  B10010,
  B10010,
  B11111
};

byte kaaf2[] = {
  B00001,
  B00010,
  B00100,
  B01000,
  B00100,
  B00010,
  B11111,
  B00000
};

void setup() {
  
  Serial.begin(4800);
  lcd_1.begin(16,2);
  displayscreen();
  pinMode(trigPin, OUTPUT); // config trigger pin to output mode
  pinMode(echoPin, INPUT);  // config echo pin to input mode
}  


void Height(){ 
digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration_us = pulseIn(echoPin, HIGH);
    
  distance_cm = 0.017 * duration_us;

  lcd_1.clear();
  lcd_1.setCursor(0, 1); 
  lcd_1.print("Height: ");
  lcd_1.print(distance_cm);
}


void displayscreen(){
  

lcd_1.setCursor(4,0);
lcd_1.print("*iScale*");
lcd_1.setCursor(2 ,1);
lcd_1.print("!Your Scale!");    
lcd_1.scrollDisplayLeft(); 
delay(200);  
lcd_1.scrollDisplayRight();  
  
}

/*void agetext(){
  
    lcd_1.createChar(12, Alef1);
    lcd_1.setCursor(16,0);
    lcd_1.write(12);
    
    lcd_1.createChar(13, Dal1);
    lcd_1.setCursor(15,0);
    lcd_1.write(13);
    
    lcd_1.createChar(14, Khaa3);
    lcd_1.setCursor(14,0);
    lcd_1.write(14);
    
    lcd_1.createChar(15, Laam3);
    lcd_1.setCursor(13,0);
    lcd_1.write(15);
    
    lcd_1.createChar(16, Seen3);
    lcd_1.setCursor(10,0);
    lcd_1.write(16);
     
    lcd_1.createChar(17, Noon2);
    lcd_1.setCursor(9,0);
    lcd_1.write(17);
    
    lcd_1.createChar(18, Kaaf1);
    lcd_1.setCursor(8,0);
    lcd_1.write(18); 
  
}*/

void loop(){
  
  static unsigned long lastKeypressTime = 0; // initialize the lastKeypressTime variable
   char customKey = customKeypad.getKey();  // variable for the input key
  
  
  if (customKey)  //if there is any input
      

  { 
    lcd_1.clear();
    lastKeypressTime = millis(); // update the lastKeypressTime variable with the current time
 
    //lcd_1.setCursor(15,0);
    //lcd_1.print("Enter your PhoneNo.:");
    
    lcd_1.createChar(0, Alef1);
    lcd_1.setCursor(15,0);
    lcd_1.write(0);
    
    lcd_1.createChar(1, Dal1);
    lcd_1.setCursor(14,0);
    lcd_1.write(1);
    
    lcd_1.createChar(2, Khaa3);
    lcd_1.setCursor(13,0);
    lcd_1.write(2);
    
    lcd_1.createChar(3, Laam3);
    lcd_1.setCursor(12,0);
    lcd_1.write(3);
    
    lcd_1.createChar(4, Rhaa1);
    lcd_1.setCursor(10,0);
    lcd_1.write(4);
     
    lcd_1.createChar(5, Qaaf1);
    lcd_1.setCursor(9,0);
    lcd_1.write(5);
    
    lcd_1.createChar(6, Meem2);
    lcd_1.setCursor(8,0);
    lcd_1.write(6);
    
    lcd_1.createChar(7, Kaaf1);
    lcd_1.setCursor(7,0);
    lcd_1.write(7);
    
    
    
    Serial.print("Enter your PhoneNo.: "); 
       class String PhoneString = ""; // Initialize an empty string to hold the user's age
    
      // Wait for the user to enter their Phone (up to 10 seconds)
     while (millis() - lastKeypressTime <= 10000) {
     
     char PhoneKey = customKeypad.getKey();
      
      // Initialize if a key is pressed
      if (PhoneKey) {
        lastKeypressTime = millis();
        
        Serial.print(PhoneKey);
        PhoneString += PhoneKey; // Append the entered digit to the age string
        lcd_1.setCursor(2,1);
        lcd_1.print(PhoneString);
        //PhoneString += PhoneKey;
        // If the age string has two digits, categorize the age
        if (PhoneString.length() == 11) {
 
        // Print the user's age and age group
        lcd_1.clear();
        lcd_1.setCursor(1,0);
        lcd_1.print("Your Phone is: ");
        lcd_1.setCursor(2,1);
        lcd_1.print(PhoneString);
        
          
        //delay(1000); 
        
        
        // Convert the age string to an integer
          int Phone = PhoneString.toInt(); 
           //lastKeypressTime = 0;
         //if (millis() -lastKeypressTime > 10000) {  
            PhoneString = "";
           delay(1000);
            Age3();
        
   
        
        } 
        }
          
       
        }
        
        
       }
        
       
  
     // }
     
  
}


int Age3() {
 
   
  int iAge;
   lcd_1.clear();
  // lcd_1.print("Enter Your Age :");
  
    lcd_1.createChar(0, Alef1);
    lcd_1.setCursor(15,0);
    lcd_1.write(0);
   /* 
    lcd_1.createChar(1, Dal1);
    lcd_1.setCursor(14,0);
    lcd_1.write(1);
    
    lcd_1.createChar(2, Khaa3);
    lcd_1.setCursor(13,0);
    lcd_1.write(2);*/
    
    lcd_1.createChar(3, Laam3);
    lcd_1.setCursor(14,0);
    lcd_1.write(3); 
     
    lcd_1.createChar(4, Seen3);
    lcd_1.setCursor(13,0);
    lcd_1.write(4);
     
    lcd_1.createChar(5, Noon2);
    lcd_1.setCursor(12,0);
    lcd_1.write(5);
    /*
    lcd_1.createChar(6, Kaaf1);
    lcd_1.setCursor(8,0);
    lcd_1.write(6); */
  
  lcd_1.setCursor(4, 1);
  char Key = NO_KEY;
  while (Key == NO_KEY) {
    Key = customKeypad.getKey();
    if (Key > '0' && Key <= '9')  iAge = Key - '0';
    else Key = NO_KEY;
  }
  Serial.print(Key);
  lcd_1.print(Key);
  Key = NO_KEY;
  while (Key == NO_KEY) {
    Key = customKeypad.getKey();
    if (Key >= '0' && Key <= '9')  iAge = iAge * 10 + Key - '0';
    else Key = NO_KEY;
  }

  Serial.print(Key);
  lcd_1.println(Key);

  lcd_1.clear();
  lcd_1.setCursor(1, 0);
  lcd_1.print("Your Age is: ");
  lcd_1.setCursor(8, 1);
  lcd_1.print(iAge);
  delay(1000);
  Gender();
  return iAge;
  
}

int Gender() {
  class String iGender;
  lcd_1.clear();
  lcd_1.print("Choose Gender:");
  delay(100); 
  lcd_1.setCursor(0, 1);
  lcd_1.print("*=Male #=Female");
  delay(500); 
  lcd_1.clear();
  lcd_1.setCursor(0, 0);
  lcd_1.print("Choose Gender:");
  lcd_1.setCursor(4, 1);
  char Key = NO_KEY;
  while (Key == NO_KEY) {
    Key = customKeypad.getKey();
    if (Key == '*')  iGender == "Male";
    else if (Key =='#')  iGender == "Female";
    else Key = NO_KEY;
  }
  Serial.print(Key);
  lcd_1.print(Key);
  Key = NO_KEY;
  while (Key == NO_KEY) {
    Key = customKeypad.getKey();
    if (Key == '*')  iGender = "Male";
    else if (Key == '#')  iGender = "Female";
    else Key = NO_KEY;
  }

  Serial.print(Key);
  lcd_1.println(Key);

  lcd_1.clear();
  lcd_1.setCursor(1, 0);
  lcd_1.print("Your are a ");
  lcd_1.setCursor(8, 1);
  lcd_1.print(iGender);
  delay(1000); 
  Receipt();
 //return iGender;
 // Height();
}

int Receipt() {
  class String iReceipt;
  lcd_1.clear();
  lcd_1.print("Print Receipt ?");
  delay(100); 
  lcd_1.setCursor(0, 1);
  lcd_1.print("*=Yes #=No");
  delay(500); 
  lcd_1.clear();
  lcd_1.setCursor(0, 0);
  lcd_1.print("Print Receipt ?");
  lcd_1.setCursor(4, 1);
  char Key = NO_KEY;
  while (Key == NO_KEY) {
    Key = customKeypad.getKey();
    if (Key == '*')  iReceipt == "Print Receipt";
    else if (Key =='#')  iReceipt == "Not to Print Receipt";
    else Key = NO_KEY;
  }
  Serial.print(Key);
  lcd_1.print(Key);
  Key = NO_KEY;
  while (Key == NO_KEY) {
    Key = customKeypad.getKey();
    if (Key == '*')  iReceipt = "Print a Receipt";
    else if (Key == '#')  iReceipt = "Not to Print ";
    else Key = NO_KEY;
  }

  Serial.print(Key);
  lcd_1.println(Key);

  lcd_1.clear();
  lcd_1.setCursor(1, 0);
  lcd_1.print("You choosed ");
  lcd_1.setCursor(0, 1);
  lcd_1.print(iReceipt);
  delay(1000); 
  Height();
  delay(3000); 
  lcd_1.clear();
  lcd_1.setCursor(4, 1);
  lcd_1.print("Thank You");
  delay(1000); 
  lcd_1.clear();
  displayscreen();
  
  
 //return iReceipt;
 // Height();
}

How is the LCD connected to the Arduino ?

Here is the connections, and works fine otherwise,
But I think I have the whole idea will not work as certainly I need much more characters to be able to write significant Arabic sentences.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.