i dont know how to use a keypad n lcd with eeprom

I have a problem to make a menu to enter the phone number and then see it.

The actions of the key:

To this, a 10-digit number must be entered, with # saved in the eeprom and with * a number that you enter is deleted.

B shows me the number I keep in the eeprom.

c main menu that indicates what A and B do

this urges me to pass my code: 'v.

Note: I am a newbie in Arduino.
esto me urge les paso mi código :'v.

nota :soy un novato en arduino.

interfaztesis.ino (3.08 KB)

The post of this link could be helpful for you.

           if(tecla)
            {
              numero[indice]=tecla;
              indice++;
              posX++;
              lcd.setCursor(posX, 1);
              lcd.print(tecla);       
            }

Even if the user has pressed 23 different keys, keep writing beyond the end of the array...

You REALLY need to make sure that there is room in the array BEFORE you write to it.

with * a number that you enter is deleted.

     case '*':                     //La tecla B sirve para borrar el caracter anterior escrito
     
        lcd.setCursor(0, 1);
        lcd.clear();
        break;

Just erasing what was on the LCD is nowhere near enough. Remember the array you are storing data in? That needs to be cleared, too. Remember the index into that array? That needs to be reset to 0, too.

      case '#':                     //La tecla C borra TODO lo escrito en la pantalla y posiciona el cursor en (0,0)
       
        EEPROM.write(eepromcaja1,indice);// Escribimos en la memoria eeprom
        menu=0;
        lcd.clear();
      
        break;

Storing the array index in EEPROM seems like a dumb thing to do. Storing the data in the array seems more useful. YMMV.

@rosswaldo

I have executed your program in a real setup. My observations are:
1. While entering 10-digit number (any combination of 0 to 9), the program also responses to C, D, and etc. Is this correct?

2. After 10-digit entry (say, 1, 2, 3, 4, ..., 9, 0), I pressed '#' to save the number in EEPROM. It looks like that some kind of action has been taken; but, there is no message/indication on the issue that the number has been saved in EEPROM. Anyway, I have assumed that the number is saved.

3. I pressed 'B' with a hope to see the number back on LCD; the number has not appeared.

I think that we need to draw the Flow Chart first that will clearly describe your program requirements. Flow Chart is a great Tool in the development of Complex Program as it provides the 'Basic Start up' onto which we can slowly add other features.

Thanks a lot for the good works that you have done so far.

@rosswaldo
The Flow Chart given below has implemented most of your functions. You can add with it other features as you want; you can also refine it.


Fig-1: Flow Chart fro Keypad

Simple C Coding for Fig-1:(Tested on UNO)

#include<EEPROM.h>
#include<Keypad.h>
#include<LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

const byte rows = 4, cols = 4;
char storage[11];   //including space for null-byte
char storageB[11];
int adr = 0x0010;
int arrayTracker = 0;
byte flag11 = 0x00;
byte flag2 = 0x00;
byte flag3 = 0x00;
char input;

char keys[rows][cols] = {
 
 {'1','2','3','a'},
 {'4','5','6','b'},
 {'7','8','9','c'},
 {'*','0','#','d'}
};

byte rPins[rows] = {9,8,7,6}, cPins[cols] = {5,4,3,2};

Keypad keypad = Keypad(makeKeymap(keys),rPins,cPins,rows,cols);

void setup()
{
 lcd.init();
 lcd.backlight();
 lcd.print("Enter 10-digit..");
 lcd.setCursor(0,1);
}

void loop()
{
  L0: input = keypad.getKey(); //L0:
  if(input)
  {                         //L1:
    if(flag2==0x00)         //L1:
    {                 //L2:
      if(flag11==0x00)//L2:      
      {//L3:
        filterDigit();      //L3: do not print *, #, a, b, c, d
        lcd.write(input);   //show digit on LCD
        storage[arrayTracker] = input;  //save digit
        if(arrayTracker == 9)  //L4
        {//L5:
          arrayTracker++;       //L5
          storage[arrayTracker] = 0x00; //null-byte
          flag11 = 0x01;
          goto L0;
        }
        else
        {     //L5A:
          arrayTracker++;   //L5A:
          goto L0;
        }
      }
      else
      {          //L3A:
        if(input == '#')    //to save in EEPROM
        {   //L3Y:
          EEPROM.put(adr, storage); //save 10-digit code in EEPROM
          delay(1000);
          lcd.setCursor(0, 1);
          lcd.print("Saved in EEPROM");
          flag2 = 0x01;
          goto L0;    //L3Y:
        }
      } 
      //----------L3 : if-else--------------------
    }

    else
    {
      if(input == '*')      //L2A:
      {  //3X:
        //delete code from array and EEPROM
        for(int i=0; i<11; i++)
        {
          storage[i] = 0x00;
          storageB[i] = 0x00;
        }
        EEPROM.put(adr, storage);   //all digits are 0s
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Codes Deleted!");
        lcd.setCursor(0, 1);
        EEPROM.get(adr, storageB);
        lcd.print(storageB);
        flag3 = 0x01;
        goto L0;
      }
      else   
      {  //L3XA:
        if(flag3 == 0x00)
        {  //L4X:
          if(input == 'b')
          {//L5X:
            //read from EEPROM and show on LCD
            EEPROM.get(adr, storageB);
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("Code from EEPROM");
            lcd.setCursor(0, 1);
            lcd.print(storageB);
          } 
         }
       }
     }     
   }
}

void filterDigit()
{
  
}