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. !
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 ?