how to manipulate a string ?????

Hello to you all !

i have an Arduino Mega 2560 with a 2x16 cld screen and a 4x4 keypad, every thing is ok connected and i runned the dynamickepad example and everything worked just fine.
i am trying to create a text string that i can add or dellete 32 characters from it and eventualy i can print the string to the lcd.
so i messed up with the example, add something here, dellete something there but i can not find a way to make it work.
i am sure that it not the most efficient code, so any suggestion is more than welcome.

Here is the code :

#include <Keypad.h>

#include <LiquidCrystal.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
// Define the keymaps.  The blank spot (lower left) is the space character.
char alphaKeys[ROWS][COLS] = {
    { 'a','d','g','A' },
    { 'j','m','p','B' },
    { 's','v','y','C' },
    { ' ','.','#','D' }
};

char numberKeys[ROWS][COLS] = {
    { '1','2','3','A' },
    { '4','5','6','B' },
    { '7','8','9','C' },
    { ' ','0','#','D' }
};

boolean alpha = false;   // Start with the numeric keypad.
char* keypadMap = (alpha == true) ? makeKeymap(alphaKeys) : makeKeymap(numberKeys);

byte rowPins[ROWS] = {48, 49, 50, 51}; 	//connect to the row pinouts of the keypad
byte colPins[COLS] = {40, 41, 43, 42}; 	//connect to the column pinouts of the keypad

//create a new Keypad
Keypad keypad = Keypad(keypadMap, rowPins, colPins, sizeof(rowPins), sizeof(colPins));

unsigned long startTime;
const byte ledPin = 13;	                                                 // Use the LED on pin 13.

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

char* myStrings[32];
int i;
void setup(){
  lcd.begin(16, 2);
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);                                                // Turns the LED on.
  keypad.addEventListener(keypadEvent);                                      // Add an event listener.
  keypad.setHoldTime(500);
}

void loop(){
  char key = keypad.getKey();
    if (alpha && millis()-startTime>100) {           // Flash the LED if we are using the letter keymap.
        digitalWrite(ledPin,!digitalRead(ledPin));
	startTime = millis();
    }
}
void keypadEvent(KeypadEvent key) {
    static char virtKey = NO_KEY;      // Stores the last virtual key press. (Alpha keys only)
    static char physKey = NO_KEY;      // Stores the last physical key press. (Alpha keys only)
    static char buildStr[12];
    static byte buildCount;
    static byte pressCount;

    switch (keypad.getState())
    {
    case PRESSED:
        if (isalpha(key)) {              // This is a letter key so we're using the letter keymap.
            if (physKey != key) {        // New key so start with the first of 3 characters.
                pressCount = 0;
                virtKey = key;
                physKey = key;
                myStrings[i] = key;
            }
            else {                       // Pressed the same key again...
                virtKey++;               // so select the next character on that key.
                pressCount++;            // Tracks how many times we press the same key.
                myStrings++;
          }
            if (pressCount > 2) {        // Last character reached so cycle back to start.
                pressCount = 0;
                virtKey = key;
            }
            lcd.print(myStrings);       // Used for testing.
        }
        if (isdigit(key) || key == ' ' || key == '.')  lcd.print(myStrings);
        if (key == '#')  lcd.println();
        break;

    case HOLD:
        if (key == '#')  {                   // Toggle between keymaps.
            if (alpha == true)  {            // We are currently using a keymap with letters
                keypad.begin(*numberKeys);   // and want to change to numbers.
                alpha = false;
                digitalWrite(ledPin, LOW);
            }
            else  {                          // Or, we are currently using a keymap with numbers
                keypad.begin(*alphaKeys);    // and want to change to letters.
                alpha = true;
            }
        }
        else  {                             // Some key other than '#' was pressed.
            buildStr[buildCount++] = (isalpha(key)) ? virtKey : key;
            buildStr[buildCount] = '\0';
            lcd.println();
            lcd.println(buildStr);
        }
        break;

    case RELEASED:
        if (buildCount >= sizeof(buildStr))  buildCount = 0;    // Our string is full. Start fresh.
        break;

    }  // end switch-case
}  // end keypad events

Moderator: CODE TAGS.

AND THIS IS THE COMPILER RESULT :

sketch_feb09b.cpp: In function 'void keypadEvent(KeypadEvent)':
sketch_feb09b:68: error: invalid conversion from 'KeypadEvent' to 'char*'
sketch_feb09b:73: error: lvalue required as increment operand
sketch_feb09b:79: error: call of overloaded 'print(char* [32])' is ambiguous
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:55: note: candidates are: size_t Print::print(char)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:56: note: size_t Print::print(unsigned char, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:57: note: size_t Print::print(int, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:58: note: size_t Print::print(unsigned int, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:59: note: size_t Print::print(long int, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:60: note: size_t Print::print(long unsigned int, int)
sketch_feb09b:81: error: call of overloaded 'print(char* [32])' is ambiguous
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:55: note: candidates are: size_t Print::print(char)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:56: note: size_t Print::print(unsigned char, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:57: note: size_t Print::print(int, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:58: note: size_t Print::print(unsigned int, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:59: note: size_t Print::print(long int, int)
C:\Users\sakis\Desktop\arduino-1.0\hardware\arduino\cores\arduino/Print.h:60: note: size_t Print::print(long unsigned int, int)

I have no idea what to do ! PLZ HELP !

Not sure about the rest but I think you might want to check this :

const byte COLS = 4; //three columns

i was using an example with a 3x4 keypad and i converted it for my 4x4 keypad ! but thanks a lot for your time !

    if (isalpha(key)) {

Just a guess: In keypadEvent you've declared key as a type keypadEvent. Can you really do an isalpha compare on a type of keypadEvent?

Perhaps the code should be

    if (isalpha(key.getKey())) {

Or perhaps you need to cast key?

Brad.

First of all Thank you all for your help !

I manage to solve a lot of my problems by simply erase all from my mind and the sketch and start all over agen. :wink: !

I still have one and this the last for today ! after that i am having a good sleep and then start for the rest of the project !

I am trying to create a text messenger ! I will pressent the code in a sec ! Now everything works just fine ( if i press the same btn agen it changes characters in the same cursor point, if i press another one the cursor moves 1 point to the right and does the same thing, when it reaches the end of a row to the lcd screen goes to the next) everything is perfect. BUT ..... i want to have a function that counts the time between btn press when i press the same bt, so if it is less than a sec to continue changing the characters but if it more than a sec to move the cursor 1 point to the right and start the same all over agen.

Here is the code so far :

#include <Keypad.h>
#include <ctype.h>
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
// Define the keymaps.  The blank spot (lower left) is the space character.
char alphaKeys[ROWS][COLS] = {
    { 'a','d','g', },
    { 'j','m','p', },
    { 's','v','y', },
    { ' ','.','#', }
};

char numberKeys[ROWS][COLS] = {
    { '1','2','3', },
    { '4','5','6', },
    { '7','8','9', },
    { ' ','0','#', }
};

boolean alpha = false;   // Start with the numeric keypad.
char* keypadMap = (alpha == true) ? makeKeymap(alphaKeys) : makeKeymap(numberKeys);

byte rowPins[ROWS] = {48, 49, 50, 51}; 	//connect to the row pinouts of the keypad
byte colPins[COLS] = {40, 41, 43, 42}; 	//connect to the column pinouts of the keypad

//create a new Keypad
Keypad keypad = Keypad(keypadMap, rowPins, colPins, sizeof(rowPins), sizeof(colPins));

unsigned long startTime;
const byte ledPin = 13;	 
int i = 0;
int j = 0;
int flag = 0;
long LastDebounceTime = 0;
long FirstDebounceTime = 0;

void setup(){
    lcd.begin(16, 2);
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin, LOW);                                                // Turns the LED on.
    keypad.addEventListener(keypadEvent);                                      // Add an event listener.
    keypad.setHoldTime(500);
};

void loop(){
  FirstDebounceTime = millis();
  
  char key = keypad.getKey();

    if (alpha && millis()-startTime>100) {           // Flash the LED if we are using the letter keymap.
        digitalWrite(ledPin,!digitalRead(ledPin));
		startTime = millis();
    }
char waitForKey();
};

// Take care of some special events.
void keypadEvent(KeypadEvent key) {
    static char virtKey = NO_KEY;      // Stores the last virtual key press. (Alpha keys only)
    static char physKey = NO_KEY;      // Stores the last physical key press. (Alpha keys only)
    static char buildStr[12];
    static byte buildCount;
    static byte pressCount;

    switch (keypad.getState())
    {
    case PRESSED:
        if (isalpha(key)) {          // This is a letter key so we're using the letter keymap.
            if (physKey != key) {        // New key so start with the first of 3 characters.
                pressCount = 0;
                virtKey = key;
                physKey = key;
            }
            else {              // Pressed the same key again...
            
                LastDebounceTime = millis() - startTime;
                if ((LastDebounceTime - startTime)>1000){
                virtKey++;               // so select the next character on that key.
                pressCount++;            // Tracks how many times we press the same key.
                i--;
                }
            }
            if (pressCount > 2) {        // Last character reached so cycle back to start.
                pressCount = 0;
                virtKey = key;
            }
            if (i == 16 & flag == 0 & j == 0){
              i = 0;
              j = 1;
              flag = 1;
              
            }
            lcd.setCursor(i,j);
            Serial.print(FirstDebounceTime);
            Serial.println();
            Serial.println(LastDebounceTime - FirstDebounceTime);
            Serial.println();
            Serial.print(LastDebounceTime);
            Serial.println();
            Serial.println(LastDebounceTime - FirstDebounceTime);
            Serial.println();
            
            Serial.print(j);
            lcd.print(virtKey);       // Used for testing.
            if (i == 15 & j == 1){
              i = 0;
              j = 0;
              flag = 0;
            }
            else {
              i++;
            };
              
      }
        if (isdigit(key) || key == ' ' || key == '.')  lcd.print(key);
        if (key == '#')  Serial.println();
        break;

    case HOLD:
        if (key == '#')  {                   // Toggle between keymaps.
            if (alpha == true)  {            // We are currently using a keymap with letters
                keypad.begin(*numberKeys);   // and want to change to numbers.
                alpha = false;
                digitalWrite(ledPin, LOW);
            }
            else  {                          // Or, we are currently using a keymap with numbers
                keypad.begin(*alphaKeys);    // and want to change to letters.
                alpha = true;
            }
        }
        else  {                             // Some key other than '#' was pressed.
            buildStr[buildCount++] = (isalpha(key)) ? virtKey : key;
            buildStr[buildCount] = '\0';
            Serial.println();
            Serial.println(buildStr);
        }
        break;

    case RELEASED:
        if (buildCount >= sizeof(buildStr))  buildCount = 0;    // Our string is full. Start fresh.
        break;

    }  // end switch-case
}  // end keypad events

it doesnt work

any help ?

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

void loop(){
  FirstDebounceTime = millis();
  
  char key = keypad.getKey();

    if (alpha && millis()-startTime>100) {           // Flash the LED if we are using the letter keymap.
        digitalWrite(ledPin,!digitalRead(ledPin));
		startTime = millis();
    }
char waitForKey();
};

Why do you have a prototype (char waitForKey():wink: inside the loop() function?

I am sorry but i didn't had time to right !

I managed to solve all of my problems except one !

i am pressenting the new code and then I am to pressend the problem.

#include <Keypad.h>
#include <ctype.h>
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
// Define the keymaps.  The blank spot (lower left) is the space character.
char alphaKeys[ROWS][COLS] = {
    { 'a','d','g', },
    { 'j','m','p', },
    { 's','v','y', },
    { ' ','.','#', }
};

char numberKeys[ROWS][COLS] = {
    { '1','2','3', },
    { '4','5','6', },
    { '7','8','9', },
    { ' ','0','#', }
};

boolean alpha = false;   // Start with the numeric keypad.
char* keypadMap = (alpha == true) ? makeKeymap(alphaKeys) : makeKeymap(numberKeys);

byte rowPins[ROWS] = {48, 49, 50, 51}; 	//connect to the row pinouts of the keypad
byte colPins[COLS] = {40, 41, 43, 42}; 	//connect to the column pinouts of the keypad

//create a new Keypad
Keypad keypad = Keypad(keypadMap, rowPins, colPins, sizeof(rowPins), sizeof(colPins));

unsigned long startTime;
const byte ledPin = 13;	 
int i = 0;
int j = 0;
int k = 0;
int flag = 0;
int flag2 = 0;
long LastDebounceTime = 0;
long FirstDebounceTime = 0;
long Time = 0;

void setup(){
    lcd.begin(16, 2);
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin, LOW);                                                // Turns the LED on.
    keypad.addEventListener(keypadEvent);                                      // Add an event listener.
    keypad.setHoldTime(500);
};

void loop(){
  
  char key = keypad.getKey();
    if (alpha && millis()-startTime>100) {           // Flash the LED if we are using the letter keymap.
        digitalWrite(ledPin,!digitalRead(ledPin));
		startTime = millis();
    }
};

// Take care of some special events.
void keypadEvent(KeypadEvent key) {
    
    FirstDebounceTime = millis();
    Time = FirstDebounceTime;
    static char virtKey = NO_KEY;      // Stores the last virtual key press. (Alpha keys only)
    static char physKey = NO_KEY;      // Stores the last physical key press. (Alpha keys only)
    static char buildStr[12];
    static byte buildCount;
    static byte pressCount;
    switch (keypad.getState())
    {
    case PRESSED:
        if (isalpha(key)) {          // This is a letter key so we're using the letter keymap.
            if (physKey != key) {        // New key so start with the first of 3 characters.
                pressCount = 0;
                virtKey = key;
                physKey = key;
                flag2 = 1;
            }
            else {                       // Pressed the same key again...
                virtKey++;               // so select the next character on that key.
                pressCount++;            // Tracks how many times we press the same key.
                i--;
                flag2 = 0;
            }
            if (pressCount > 2) {        // Last character reached so cycle back to start.
                pressCount = 0;
                virtKey = key;
            }
            if (i == 16 & flag == 0 & j == 0){      //if cursor is at the end of the first row goto second
              i = 0;                                        // row first point
              j = 1;
              flag = 1;
              
            }
            lcd.setCursor(i,j);
            lcd.print(virtKey);       // Used for testing.
            if (i == 15 & j == 1){   // when the cursor is to the end of the second row go back to the
              i = 0;                      // firts point in the first row
              j = 0;
              flag = 0;
            }
            else {
              i++;
            };
              
      }
        if (isdigit(key) || key == ' ' || key == '.')  lcd.print(key);
        if (key == '#')  Serial.println();
        break;

case HOLD:
        if (key == '#')  {                   // Toggle between keymaps.
            if (alpha == true)  {            // We are currently using a keymap with letters
                keypad.begin(*numberKeys);   // and want to change to numbers.
                alpha = false;
                digitalWrite(ledPin, LOW);
            }
            else  {                          // Or, we are currently using a keymap with numbers
                keypad.begin(*alphaKeys);    // and want to change to letters.
                alpha = true;
            }
        }
        else  {                             // Some key other than '#' was pressed.
            buildStr[buildCount++] = (isalpha(key)) ? virtKey : key;
            buildStr[buildCount] = '\0';
            Serial.println();
            Serial.println(buildStr);
        }
        break;

    case RELEASED:
        if (buildCount >= sizeof(buildStr))  buildCount = 0;    // Our string is full. Start fresh.
        break;

    }  // end switch-case
}  // end keypad events

the problem now is that i can not find a way to count time between 2 presses !
right now if i press multiple time the same key it prints to the lcd to the same cursor point deferent characters.
example i press 6 times the 1 key and it pritnts A the first time B the second .... Cthe sixth but in the same cusor point. cursor point will move one to the right only if i press an other key.
what i want to do is also move the cursor one to the right if time between 2 press at the same key is more than 1 sec.

Just like a cell phone works.

i created 3 variable FirstDebounceTime, LastDebounceTime and time
but i can't get a proper timer to work until now, while allways First and Last DebounceTime vars have the same time.

is there any help with that ?

void loop(){
  
  char key = keypad.getKey();
    if (alpha && millis()-startTime>100) {           // Flash the LED if we are using the letter keymap.
        digitalWrite(ledPin,!digitalRead(ledPin));
		startTime = millis();
    }
};

The call to getKey() is useless, since you don't use the returned value.

long LastDebounceTime = 0;
long FirstDebounceTime = 0;
long Time = 0;

Debouncing is taken care of in the keypad library. Therefore, these names are completely meaningless in terms of describing the value that they will hold. Some better names would really help.

int flag = 0;
int flag2 = 0;

The same holds true for these names. If you can't come up with meaningful names, there is a problem with the logic that requires these variables.

the problem now is that i can not find a way to count time between 2 presses !

Where are you measuring the time interval? In loop. Where are you recording the time? You store the same time in Time and FirstDebounceTime in keypadEvent REGARDLESS OF THE TYPE OF EVENT.

Now, think about whether recording the time twice is reasonable, and whether the event type matters. I think that you will agree that it does, and that only one time value is needed, and that it is recorded in the wrong place.

kourpetis:
but i can't get a proper timer to work until now, while allways First and Last DebounceTime vars have the same time.

is there any help with that ?

Well in the code you posted you never set 'LastDebounceTime' to a non-zero value so I'm not sure how you expect that to work.

Brad.

I am sorry but i am not that good in programming, i remember that there is some kind logical flow on reading time between 2 evens but i can't come up wit anything.

I am thinking of start count just after " switch PRESSED : "
but stil i don't know how to create a counter.

PLEASE HELP ME !

i remember that there is some kind logical flow on reading time between 2 evens but i can't come up wit anything.

When one event occurs, note the time. When that same event (or a different event occurs again, you can then subtract the previously recorded time from the current time, to get the interval.

You want to record when a key is pressed, so add the call to millis() in the case PRESSED: case.

When another PRESSED event occurs, you can compute the interval, but, you only want to do this if the SAME key is pressed.

Make sure that the variable that you record the time in is named appropriately. Time and LastDebounceTime are not appropriate for this usage.

Sorry for not posting.
I was out of town.

Finaly got it to work

#include <Keypad.h>
#include <ctype.h> // include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
// Define the keymaps.  The blank spot (lower left) is the space character.
char alphaKeys[ROWS][COLS] = {
  { 'a','d','g', },
  { 'j','m','p', },
  { 's','v','y', },
  { ' ','.','#', }
};

char numberKeys[ROWS][COLS] = {
  { '1','2','3', },
  { '4','5','6', },
  { '7','8','9', },
  { ' ','0','#', }
};

boolean alpha = false;   // Start with the numeric keypad.
char* keypadMap = (alpha == true) ? makeKeymap(alphaKeys) : makeKeymap(numberKeys);

byte rowPins[ROWS] = {37, 35, 33, 31}; 	//connect to the row pinouts of the keypad
byte colPins[COLS] = {47, 43, 41, 39}; 	//connect to the column pinouts of the keypad

//create a new Keypad
Keypad keypad = Keypad(keypadMap, rowPins, colPins, sizeof(rowPins), sizeof(colPins));

unsigned long startTime;
const byte ledPin = 13;	 
int i = 0;
int j = 0;
long puss=0;
long puss2=1;
int flag=0;
int flag2=1;
int flag3=0;
char message[33];
int space = 32;

void setup(){
  lcd.begin(16, 2);
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);                                                // Turns the LED on.
  keypad.addEventListener(keypadEvent);                                      // Add an event listener.
  keypad.setHoldTime(500);

};

void loop(){
  char key = keypad.getKey();
  if (alpha && millis()-startTime>100) {           // Flash the LED if we are using the letter keymap.
    digitalWrite(ledPin,!digitalRead(ledPin));
    startTime = millis();
  }
};

// Take care of some special events.
void keypadEvent(KeypadEvent key) {
  static char virtKey = NO_KEY;      // Stores the last virtual key press. (Alpha keys only)
  static char physKey = NO_KEY;      // Stores the last physical key press. (Alpha keys only)
  static char buildStr[12];
  static byte buildCount;
  static byte pressCount;
  switch (keypad.getState())
  {
  case PRESSED:
    if (flag2==0) {              // Pressed the same key again...
      puss=millis();
      if (puss != puss2){
        if ((puss - puss2)>1000){
          flag3=1;
        } 
        else {
          flag3=0;
        }
        puss2=millis();
      }

    }
    if (isalpha(key)) {          // This is a letter key so we're using the letter keymap.
       if (physKey != key) {        // New key so start with the first of 3 characters.
        pressCount = 0;
        virtKey = key;
        physKey = key;
        flag2 = 1;
      }
      else {              // Pressed the same key again...
        if (flag3==1){
          virtKey++;               // so select the next character on that key.
          pressCount++;            // Tracks how many times we press the same key.
          flag2 = 0;
        } 
        else {
          virtKey++;               // so select the next character on that key.
          pressCount++;            // Tracks how many times we press the same key.
          i--;
          flag2 = 0;
        }
      }
    }

    if (pressCount > 2) {        // Last character reached so cycle back to start.
      pressCount = 0;
      virtKey = key;
    }
    if (i >= 16 & flag == 0 & j == 0){ 
      i = 0;
      j = 1;
      flag = 1;
     message[i]= 'virtKey';
    }
    lcd.setCursor(i,j);
    lcd.print(virtKey);      // Used for testing.
    Serial.print(virtKey);
    Serial.print(message[i]);
    if (i >= 15 & j == 1){
      i = 0;
      j = 0;
      flag = 0;
    }
    else {
      i++;
    };
    if (isdigit(key) || key == ' ' || key == '.'){  
        lcd.write(key);
        Serial.write(space);
        i++;
      }
    break;

  case HOLD:
    if (key == '#')  {                   // Toggle between keymaps.
      if (alpha == true)  {            // We are currently using a keymap with letters
        keypad.begin(*numberKeys);   // and want to change to numbers.
        alpha = false;
        digitalWrite(ledPin, LOW);
      }
      else  {                          // Or, we are currently using a keymap with numbers
        keypad.begin(*alphaKeys);    // and want to change to letters.
        alpha = true;
      }
    }
    else  {                             // Some key other than '#' was pressed.
      buildStr[buildCount++] = (isalpha(key)) ? virtKey : key;
      buildStr[buildCount] = '\0';
      Serial.println();
      Serial.println(buildStr);
    }
    break;

  case RELEASED:
    if (buildCount >= sizeof(buildStr))  buildCount = 0;    // Our string is full. Start fresh.
    break;

  }  // end switch-case
}  // end keypad events

Now everything is working to the lcd like a mobile phone. if you press the same btn in less than 1 sec between presses it just changes the 3 characters of that key. if you don't press a key for a sec or you press another key the cursor moves one position to the right. :wink: !
but i have an other problem, * and 0 are " " and "." but when i press them it shows the last character in that time pressed and " " or "."

any suggestions ?