title: Input a number with Keypad and storing a number to EEPROM
body: <p>Hi there I don't have very much experience in coding just a basic staff so I need help </p>
  
  <p>but I need modification like:
  First when user press "#" key he has to write the number which will be like a price for a product, 
  Second when user press "A" key the price/number has to be stored to EEPROM memory, 
  Third when user press "B" key the price/number has to be read from EEPROM memory, </p>
  
  <p>when I press "*" key its working but this is not a number from memory this is just a printed number to LCD,</p>
  
  <p>my problem is when I press "B" key on LCD I get some strange characters</p>
  
  <p>I need code to work with EEPROM</p>
  
  <p>this is my code:</p>
  
  <pre><code>#include &lt;LiquidCrystal_I2C.h&gt;
  #include &lt;Wire.h&gt;
  #include &lt;EEPROM.h&gt;
  LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
  #include &lt;Keypad.h&gt; //include keypad library - first you must install library (library link in the video description)
  
  const byte rows = 4; //number of the keypad's rows and columns
  const byte cols = 4;
  
  char keyMap [rows] [cols] = { //define the cymbols on the buttons of the keypad
  
    {'1', '2', '3', 'A'},
    {'4', '5', '6', 'B'},
    {'7', '8', '9', 'C'},
    {'*', '0', '#', 'D'}
  };
  
  byte rowPins [rows] = {4, 5, 6, 7}; //pins of the keypad
  byte colPins [cols] = {8, 9, 10, 11};
  
  Keypad myKeypad = Keypad( makeKeymap(keyMap), rowPins, colPins, rows, cols);
  
  
  void setup() {
  
    // Setup size of LCD 16 characters and 2 lines
    lcd.begin(16, 2);
    // Back light on
    lcd.backlight();
  }
  
  void loop()
  {
    // user input array; 10 digits and nul character
    static char userinput[11];
    // variable to remember where in array we will store digit
    static int count = 0;
   char number;
  
    char key = myKeypad.getKey();
  
    if (key != NO_KEY)
    {
  
      lcd.print(key);
    }
  
    switch (key)
    {
      case NO_KEY:
        // nothing to do
        break;
  
      case '#':
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(F("Press a number:"));
        // clear the current user input
        lcd.setCursor(0, 2);
        memset(userinput, 0, sizeof(userinput));
        number=(userinput, 0, sizeof(userinput));
        // reset the counter
        count = 0;
        break;
  
      case 'A':           //Store number to memory
        EEPROM.write(0, number);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(F("Saved"));
        break;
  
      case 'B':           //Get number from memory and print to LCD
        number = EEPROM.read(0);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(F("Saved Number is:"));
        lcd.setCursor(0, 2);
        lcd.println(number);//print the stored number
        break;
  
      case '*':
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(F("Number:"));
        lcd.setCursor(0, 2);
        lcd.println(userinput);//print the stored number
        break;
  
      default:
        // if not 10 characters yet
        if (count &lt; 10)
        {
          // add key to userinput array and increment counter
          userinput[count++] = key;
        }
        break;
    }
  
  
    //delay(200);
  }
  </code></pre>