QUESTION ON: writing more than 8 char on the LCD simultaneously with arduino

hi, I can not write more than 8 new characters on my 4*20 LCD, it seems that after 8 chars the string repeat again!!

I send tow different string "HEATING" & "COOLING" to lcd via farsiprint , and what I see is printing both string in two different place at the same time,
at x=12 , y=0 : HEATING str and at x=5 , y=2 agin: HEATING str is on and 100 mily secs later
at x=12 , y=0 : COOLING str and at x=5 , y=2 agin: COOLING str is on and 100 mily secs later and so on

hear is my code (partly):
first : definition of chars
next: definition of functions
and then calling functions
I have no syntax error and no problem in writing english

byte myfont[27][8]= {
  {    
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00                        }
  ,// 0 ff
  {    
    0x03,0x07,0x04,0x02,0x01,0x1F,0x00,0x00                        }
  ,// 1 ?
  {    
    0x00,0x02,0x07,0x00,0x0B,0x1F,0x00,0x00                        }
  ,// 2 ?
  {    
    0x00,0x00,0x00,0x03,0x07,0x1B,0x00,0x00                        }
  ,// 3 ?
  {    
    0x00,0x00,0x00,0x00,0x02,0x1E,0x00,0x0C                        }
  ,// 4 ?
  {    
    0x00,0x00,0x00,0x0A,0x12,0x12,0x1E,0x00                        }
  ,// 5 ?
  {    
    0x00,0x00,0x00,0x00,0x0B,0x1F,0x00,0x00                        }
  ,// 6 ?    saad
  {    
    0x02,0x0E,0x08,0x04,0x04,0x04,0x04,0x00                        }
  ,// 7 ?
  {    
    0x00,0x00,0x00,0x08,0x04,0x04,0x018,0x00                        }
  ,// 8 ?
  {    
    0x00,0x00,0x00,0x06,0x01,0x1F,0x00,0x02                        }
  ,// 9 ?
  {    
    0x00,0x00,0x00,0x01,0x01,0x01,0x02,0x0C                        }
  ,//10 ?
  {    
    0x00,0x04,0x04,0x04,0x04,0x03,0x00,0x00                        }
  ,//11 ?
  {    
    0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00                        }
  ,//12 ?
  {    
    0x00,0x00,0x03,0x03,0x0F,0x08,0x08,0x08                        }
  ,//13 ?
  {    
    0x00,0x00,0x04,0x06,0x0A,0x0E,0x00,0x00                        }
  ,//14 ?
  {    
    0x00,0x02,0x00,0x06,0x01,0x1F,0x00,0x00                        }
  ,//15 ?
  {    
    0x00,0x08,0x08,0x0B,0x0D,0x1F,0x00,0x00                        }
  ,//16 ?
  {    
    0x00,0x00,0x00,0x03,0x03,0x01,0x02,0x0C                        }
  ,//17 ?
  {    
    0x00,0x00,0x00,0x00,0x01,0x1F,0x00,0x04                        }
  ,//18 ?
  {    
    0x00,0x00,0x01,0x00,0x01,0x01,0x02,0x0C                        }
  ,//19 ?
  {
    0x00,0x00,0x00,0x03,0x14,0x12,0x1e,0x00                        }
  ,// 20 ye
  {
    0x00,0x00,0x00,0x08,0x04,0x07,0x0C,0x00                        }
  ,// 21 ?
  {
    0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x30                       }
  ,//22 ?-
  {
    0x00,0x01,0x01,0x01,0x01,0x1E,0x00,0x00                        }
  ,  //23 ?
  {
    0x00,0x10,0x10,0x13,0x17,0x9B,0x00,0x00                        }
  ,// 24 ??
  {
    0x00,0x14,0x14,0x14,0x15,0x1f,0x00,0x02                        }
  ,// 25 ???
  {
    0x00,0x07,0x04,0x02,0x01,0x1F,0x00,0x00                        }
  ////261 ?

};

int HEATING[]      = {  
 10 , 8 ,0, 5, 21, 2, 0, 13, 22, 1 };       //1:garm shodan
int COOLING[]      = {  
  5, 21, 2, 0, 8, 22, 6 };        //2:sard shodan


//.........................................................................
Display::Display():
iLcd(6, 7, 8, A5, 16, 17),
iLastState(Thermocycler::EStartup) {

  iLcd.begin(20, 4);
//...
}

//...............................FARSIPRINT.....................................
void Display::farsiprint(int* fstr, int lent, int x, int y)
{
  for (int ii=0; ii<lent ; ii++){
    charnum = fstr[ii];
    int hh=0;
    hh = ii%8;
    iLcd.createChar(hh, myfont[charnum]);
    iLcd.setCursor(x+ii,y);
    iLcd.write(byte(hh));
    //delay(100);
  }
}
//..........................................................................
void Display:main(){
        farsiprint(HEATING, 5, 12, 0);
        delay(100);
        //iLcd.clear();
        farsiprint(COOLING, 6, 5, 2);
        delay(100);
        //iLcd.clear();
}
//.....................................................................

Please go back and edit your first post and put the code inside [ code] [ /code] tags to make it easier for us to read. Also, please include the entire sketch, not just the parts you think are important.

I think the problem is that there are only 8 programmable characters available, so as you overwrite the old ones will also change on the LCD screen. Your code seems to create a new character each time you increment the loop. This will loop around at 8 (even without your %8), which I think is the cause of your problem.

Sorry, I find your description a little hard to follow.

please check my code again
regards

Edit your first post.

Using tags, your code post should look like this:

code here...

I still don't understand your description. What is it not doing that you expect/want it to do?

hi, I can not write more than 8 new characters on my 4*20 LCD, it seems that after 8 chars the string repeat again!!

You cannot create more than 8 programmable characters.

If you look at the table of character codes and their addresses (Table 4) of the HD44780U data sheet you will see that the 8 programmable characters map into the upper eight locations in the first column and they are duplicated in the lower eight locations.

This is why programmable characters 0-7 appear to repeat when you try to use programmable characters 8 - 15.

Don

I have a 4*20 LCD not a HD...one

byte myfont[27][8]= {
  {    
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00                        }
  ,// 0 ff
  {    
    0x03,0x07,0x04,0x02,0x01,0x1F,0x00,0x00                        }
  ,// 1 ?
  {    
    0x00,0x02,0x07,0x00,0x0B,0x1F,0x00,0x00                        }
  ,// 2 ?
  {    
    0x00,0x00,0x00,0x03,0x07,0x1B,0x00,0x00                        }
  ,// 3 ?
  {    
    0x00,0x00,0x00,0x00,0x02,0x1E,0x00,0x0C                        }
  ,// 4 ?
  {    
    0x00,0x00,0x00,0x0A,0x12,0x12,0x1E,0x00                        }
  ,// 5 ?
  {    
    0x00,0x00,0x00,0x00,0x0B,0x1F,0x00,0x00                        }
  ,// 6 ?    saad
  {    
    0x02,0x0E,0x08,0x04,0x04,0x04,0x04,0x00                        }
  ,// 7 ?
  {    
    0x00,0x00,0x00,0x08,0x04,0x04,0x018,0x00                        }
  ,// 8 ?
  {    
    0x00,0x00,0x00,0x06,0x01,0x1F,0x00,0x02                        }
  ,// 9 ?
  {    
    0x00,0x00,0x00,0x01,0x01,0x01,0x02,0x0C                        }
  ,//10 ?
  {    
    0x00,0x04,0x04,0x04,0x04,0x03,0x00,0x00                        }
  ,//11 ?
  {    
    0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x00                        }
  ,//12 ?
  {    
    0x00,0x00,0x03,0x03,0x0F,0x08,0x08,0x08                        }
  ,//13 ?
  {    
    0x00,0x00,0x04,0x06,0x0A,0x0E,0x00,0x00                        }
  ,//14 ?
  {    
    0x00,0x02,0x00,0x06,0x01,0x1F,0x00,0x00                        }
  ,//15 ?
  {    
    0x00,0x08,0x08,0x0B,0x0D,0x1F,0x00,0x00                        }
  ,//16 ?
  {    
    0x00,0x00,0x00,0x03,0x03,0x01,0x02,0x0C                        }
  ,//17 ?
  {    
    0x00,0x00,0x00,0x00,0x01,0x1F,0x00,0x04                        }
  ,//18 ?
  {    
    0x00,0x00,0x01,0x00,0x01,0x01,0x02,0x0C                        }
  ,//19 ?
  {
    0x00,0x00,0x00,0x03,0x14,0x12,0x1e,0x00                        }
  ,// 20 ye
  {
    0x00,0x00,0x00,0x08,0x04,0x07,0x0C,0x00                        }
  ,// 21 ?
  {
    0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x30                       }
  ,//22 ?-
  {
    0x00,0x01,0x01,0x01,0x01,0x1E,0x00,0x00                        }
  ,  //23 ?
  {
    0x00,0x10,0x10,0x13,0x17,0x9B,0x00,0x00                        }
  ,// 24 ??
  {
    0x00,0x14,0x14,0x14,0x15,0x1f,0x00,0x02                        }
  ,// 25 ???
  {
    0x00,0x07,0x04,0x02,0x01,0x1F,0x00,0x00                        }
  ////261 ?

};

int HEATING[]      = {  
 10 , 8 ,0, 5, 21, 2, 0, 13, 22, 1 };       //1:garm shodan
int COOLING[]      = {  
  5, 21, 2, 0, 8, 22, 6 };        //2:sard shodan


//.........................................................................
Display::Display():
iLcd(6, 7, 8, A5, 16, 17),
iLastState(Thermocycler::EStartup) {

  iLcd.begin(20, 4);
//...
}

//...............................FARSIPRINT.....................................
void Display::farsiprint(int* fstr, int lent, int x, int y)
{
  for (int ii=0; ii<lent ; ii++){
    charnum = fstr[ii];
    int hh=0;
    hh = ii%8;
    iLcd.createChar(hh, myfont[charnum]);
    iLcd.setCursor(x+ii,y);
    iLcd.write(byte(hh));
    //delay(100);
  }
}
//..........................................................................
void Display:main(){
        farsiprint(HEATING, 5, 12, 0);
        delay(100);
        //iLcd.clear();
        farsiprint(COOLING, 6, 5, 2);
        delay(100);
        //iLcd.clear();
}
//.....................................................................

zshayeq:
I have a 4*20 LCD not a HD...one

That may be true.

But it still is controlled by a chip that thinks it is an HD44780. So - no difference.

iLcd.begin(20, 4);

I tend to avoid anything having a name beginning with a lowercase 'i'.

Don