amc12
#1
hi can you please help me with this i try many things can any one please tell what do
#include <EEPROM.h>
#include <Keypad.h>
char targetamount[4]={0,0,0,0};
char customKey=0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {3,4,5,6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7,8,9,10}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600);void loop()
{
targetamount=EEPROM.read(int(targetamount));
// targetamount[c]=EEPROM.read(c);
Serial.println(targetamount);char customKey = customKeypad.getKey();
if ( customKey == '*')
{
target();
}
// delay(1);
}
void target()
{
int r = 0;
int c = 4;
Serial.println("Enter the amount you want to saved");
while (r<4)
{
char key=char(customKeypad.getKey());
if (key)
{
targetamount[r] = key;
Serial.print(key);
EEPROM.write(c,key);
r++;
c++;
}
}
Serial.print("taget amount saved");
customKey = 0;
}
void setup()
{
Serial.begin(9600);void loop()
{
Look at that carefully. If you can't see a problem with it, have a look at the Blink example and see how its setup and loop functions are defined.
Pete
amc12
#3
i try this code but it still have that error
#include <EEPROM.h>
#include <Keypad.h>
char targetamount[4]={0,0,0,0};
char customKey=0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {3,4,5,6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7,8,9,10}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600);
}
void loop()
{
// targetamount=EEPROM.read(int(targetamount));
targetamount=EEPROM.read(targetamount);
Serial.println(targetamount);
char customKey = customKeypad.getKey();
if ( customKey == '*')
{
target();
}
}
void target()
{
int r = 0;
int c = 4;
Serial.println("Enter the amount you want to saved");
while (r<4)
{
char key=char(customKeypad.getKey());
if (key)
{
targetamount[r] = key;
Serial.print(key);
EEPROM.write(c,key);
r++;
c++;
}
}
Serial.print("taget amount saved");
customKey = 0;
}
please help with this
Delta_G
#4
Which line does it say the error is on?
You are not passing the correct parameters to the EEPROM read and write. Read takes an address as its argument.
for(int i = 0; i < 4; i++)
{
targetamount[i] = EEPROM.read(i);
}
Write take an address and the value to write.
while (r<4)
{
char key=char(customKeypad.getKey());
if (key)
{
targetamount[r] = key;
Serial.print(key);
EEPROM.write(r,targetamount[r]);
r++;
c++;
}
}
amc12
#6
it works thanks a lot for all your help i really appreciate it god bless you this is now my code
#include <EEPROM.h>
#include <Keypad.h>
char targetamount[4]={0,0,0,0};
char customKey=0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {3,4,5,6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7,8,9,10}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600);
}
void loop()
{
char customKey = customKeypad.getKey();
if (customKey == '#')
{
for(int i = 0; i < 4; i++)
{
Serial.println(targetamount[i] = EEPROM.read(i));
}
}
if ( customKey == '*')
{
target();
}
// delay(1);
}
void target()
{
int r = 0;
int c = 4;
Serial.println("Enter the amount you want to saved");
while (r<4)
{
char key=char(customKeypad.getKey());
if (key)
{
targetamount[r] = key;
Serial.print(key);
EEPROM.write(r,targetamount[r]);
r++;
c++;
}
}
Serial.print("taget amount saved");
customKey = 0;
}