#include<Keypad.h>
#include<LiquidCrystal_I2C.h>
#include<EEPROM.h>
#include <LiquidCrystal.h>
bool f1 = false, f2 = false, f3 = false;
const byte rows = 4; //four rows
const byte cols = 4; //four columns
char priceArray[13] = ""; //to store four digit price + null-byte
char priceRead[13] = "";
char priceArray1[13] = ""; //to store four digit price + null-byte
char priceRead1[13] = "";
int i = 0;
int dial =0;
int adress;
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
char keyMap[rows][cols] =
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[rows] = {5, 4, 3, 2}; //R1R2R3R4 connection Pin = 4567
byte colPins[cols] = {A3, A2, A1, A0}; //C1C2C3C4 connection Pin = 891011
Keypad myKeypad = Keypad(makeKeymap(keyMap), rowPins, colPins, rows, cols); //Library Function
int mode=1;
void setup()
{
lcd.begin(16, 2);
//lcd.init();
// lcd.backlight();
lcd.print("jmd electroniks");
delay(2000);
lcd.setCursor(0, 0); //cursor position DP0 Top Line
lcd.clear();
EEPROM.write(100,"HAI");
}
void loop()
{
char input = myKeypad.getKey(); //scan keypad
if(input=='C'|| mode ==1){lcd.clear(); lcd.print("press # enter no");mode=0;}
if (input != 0x00) //key pressed
{
if (f1 == true)
{
if(input == '*'){input = '+';}
lcd.print(input);
priceArray[i] = input;
i++;
if (i == 13)
{
EEPROM.put(adress, priceArray);
lcd.setCursor(0, 1);
lcd.print("Saved!");
f2 = true;
f1 = false;
}
}
if (input == 'B'|| mode==10)
{ mode=10;
lcd.setCursor(0, 1);
lcd.print("enter adress ");
if(input=='1'){
EEPROM.get(1, priceRead);
lcd.setCursor(0, 1);
lcd.print("Got");
lcd.print(priceRead);
f2 == false ;
mode=0;}
if(input=='2'){
EEPROM.get(20, priceRead);
lcd.setCursor(0, 1);
lcd.print("Got");
lcd.print(priceRead);
f2 == false ;
mode=0;}
}
}
if (input == '#'|| dial == 1)
{dial= 1;
lcd.setCursor(0, 1);
lcd.print("enter adress");
if(input=='1'){lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(">");
f1 = true;
lcd.setCursor(2, 1); //DP7, TL
dial=0;
adress=1;
}
if(input=='2'){lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(">");
f1 = true;
lcd.setCursor(2, 1); //DP7, TL
dial=0;
adress=20;
}
}
}