A lot of my boards work with RF remotes as backups. Right now I have to program each remote individually for when they put out a different code. SO, I am trying to condense the remote code part of my program to be able to use more different remotes with less code written by reading just the number 1 button of the remote, then storing that 7 digit number into eeprom, and then using this number, I can add to that number a different amount to get all my other buttons codes. I am having issues putting the 7 digit # into eeprom and then retrieving it to use and or refer/compare to it in further code.
to explain a little better..Say one remote puts out a number of 5592323 with button one. Button 2 would be 9 more than that (5592332) buttons 3-4-5 etc are also each a certain amount above the button code number so each one has a slightly higher number that the 5592323.
I need to write the 5592323 into the eeprom. Then read that number from the eeprom and use it in a function and also add to that retrieved number for another function.
Attached is a snippet of what the code might look like.
FYI, my code works fine now but I have to write 4 instances of each code and put in each number for each remote into each instance and that takes times and space to do,so I am looking for a different option.
THANKS Fran
unsigned long int RF_data = Remote.getReceivedValue();
unsigned long int RemoteVAL = EEPROM.read(7);
unsigned long SW1 = RemoteVAL
unsigned long SW2 = (RemoteVAL + 9)
unsigned long SW3 = (RemoteVAL + 11)
unsigned long SW4 = (RemoteVAL + 45)
if (RF_data == 5592323) //SW1 SETS THE BASE VALUE IN EEPROM
EEPROM.write (7,'5592323');
if (RF_data == SW2) // SHOULD BE VALUE OF 5592332 (5592323+9)
{digitalWrite(PIN_A, HIGH);
Remote.resetAvailable();
delay (150);
{digitalWrite(PIN_A, LOW);
}
}
if (RF_data == SW3) // SHOULD BE VALUE OF 5592335
{digitalWrite(PIN_B, HIGH);
Remote.resetAvailable();
delay (150);
{digitalWrite(PIN_B, LOW);
}
}
if (RF_data == SW4) // SHOULD BE VALUE OF 5592368
{digitalWrite(PIN_C, HIGH);
Remote.resetAvailable();
delay (150);
{digitalWrite(PIN_C, LOW);
}
}
/*sample of four remotes output codes is below.Each remote has 12 buttons so the lists go on.
remote1 remote2 remote3 remote4
UP AT SW1 5592323 5592067 5591299 5588227
SW1 value 5592323
LEFT AT SW2 5592332 5592076 5591308 5588236
SW1 value +9
RIGHT AT SW3 5592335 5592079 5591311 5588239
SW1 value +11
DOWN AT SW4 5592368 5592112 5591344 5588272
SW1 value +45
*/