Problem with EEPROM writing
Hi I have been trying to make this code where it simulates a bank account on an Arduino nano. I have a Atmega328P (old bootloader). My code is shown below. I am getting this error that says:
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino: In function 'void account()':
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:58:28: error: no matching function for call to 'EEPROMClass::get(int&)'
money = EEPROM.get(actnum);
^
In file included from C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:4:0:
C:\Users\palla\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src/EEPROM.h:130:31: note: candidate: template<class T> T& EEPROMClass::get(int, T&)
template< typename T > T &get( int idx, T &t ){
^~~
C:\Users\palla\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src/EEPROM.h:130:31: note: template argument deduction/substitution failed:
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:58:28: note: candidate expects 2 arguments, 1 provided
money = EEPROM.get(actnum);
^
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:63:17: error: invalid operands of types 'const char [2]' and 'float' to binary 'operator+'
lcd.print("$" + money);
~~~~^~~~~~~
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino: In function 'void charge(float)':
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:77:28: error: no matching function for call to 'EEPROMClass::get(int&)'
money = EEPROM.get(actnum);
^
In file included from C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:4:0:
C:\Users\palla\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src/EEPROM.h:130:31: note: candidate: template<class T> T& EEPROMClass::get(int, T&)
template< typename T > T &get( int idx, T &t ){
^~~
C:\Users\palla\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src/EEPROM.h:130:31: note: template argument deduction/substitution failed:
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:77:28: note: candidate expects 2 arguments, 1 provided
money = EEPROM.get(actnum);
^
C:\Users\palla\Documents\Arduino\Cash_Register\Cash_Register.ino:86:5: error: 'bob' was not declared in this scope
bob = String(actnum) + k.getKey();
^~~
exit status 1
Compilation error: no matching function for call to 'EEPROMClass::get(int&)'
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27,16,2);
float money;
int i=0;
const char number_of_rows = 4;
const char number_of_columns = 4;
char row_pins[number_of_rows] = {2, 3, 4, 5};
char column_pins[number_of_columns] = {6, 7, 8, 9};
char key_array[number_of_rows][number_of_columns] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
Keypad k = Keypad(makeKeymap(key_array),row_pins , column_pins, number_of_rows, number_of_columns);
char key_pressed;
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
lcd.backlight();
lcd.setBacklight(HIGH);
}
void loop()
{
key_pressed = k.getKey();
if(key_pressed)
{
if(key_pressed == "B"){
account();
}
if(key_pressed == "C"){
}
}
}
void account(){
int actnum;
lcd.setCursor(0,0);
lcd.print("Enter Account ID: ");
lcd.setCursor(0,1);
while(k.getKey()!='#'){
if(k.getKey() != '#'){
lcd.print(k.getKey());
String bob = String(actnum) + k.getKey();
actnum = bob.toInt();
}
}
money = EEPROM.get(actnum);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Account Balance: ");
lcd.setCursor(0, 1);
lcd.print("$" + money);
}
void charge (float amount){
int actnum;
lcd.setCursor(0,0);
lcd.print("Enter Account ID: ");
lcd.setCursor(0,1);
while(k.getKey()!='#'){
if(k.getKey() != '#'){
lcd.print(k.getKey());
String bob = String(actnum) + k.getKey();
actnum = bob.toInt();
}
}
money = EEPROM.get(actnum);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Charge Amount: ");
lcd.setCursor(0, 1);
float amt;
while(k.getKey()!='#'){
if(k.getKey() != '#'){
lcd.print(k.getKey());
bob = String(actnum) + k.getKey();
amt = bob.toInt();
}
}
money = money+amt;
EEPROM.write(actnum, money);
}
Can you please tell my how to fix this problem and what i can do to make it better?