Hello there!
I am using an ESP8266 nodemcu v3.
i am very newbie at arduino.
i have this sketch to display a 4digit on my P10 led modules panel.
i want to store the value of variables somewhere and when lost power and restart then read and display those last values again.
#include <DMDESP.h>
#include <RCSwitch.h>
#include <fonts\DIGITS_14X32.h>
#define DISPLAYS_WIDE 2
#define DISPLAYS_HIGH 2
DMDESP Disp(DISPLAYS_WIDE, DISPLAYS_HIGH);
RCSwitch rf = RCSwitch();
int Brightness, euro, han, dec, cent = 1;
void setup() {
Disp.start();
Disp.setBrightness(253);
Disp.setFont(DIGITS_14X32);
rf.enableReceive(2);
}
void loop() {
Disp.loop();
if (rf.available()) {
if (rf.getReceivedValue() == 10281618) {
euro = euro + 1;
if (euro > 9) { euro = 0; }
} else if (rf.getReceivedValue() == 10035008) {
han = han + 1;
if (han > 9) { han = 0; }
} else if (rf.getReceivedValue() == 9970490) {
dec = dec + 1;
if (dec > 9) { dec = 0; }
} else if (rf.getReceivedValue() == 9970490) {
cent = cent + 1;
if (cent > 9) { cent = 0; }
}
rf.resetAvailable();
}
Disp.setFont(DIGITS_14X32);
char euro_sf[3];
sprintf(euro_sf,"%1d", euro);
Disp.drawText(0, 0, euro_sf);
Disp.drawRect(15, 28, 16, 31);
char han_sf[3];
sprintf(han_sf, "%1d", han);
Disp.drawText(18, 0, han_sf);
char dec_sf[3];
sprintf(dec_sf, "%1d", dec);
Disp.drawText(32, 0, dec_sf);
char cent_sf[3];
sprintf(cent_sf, "%1d", cent);
Disp.drawText(46, 0, cent_sf);
}
My crystal ball is broken.
Have you read the EEPROM tutorial material?
Do you have questions about how to integrate something? You're not new to the list, but perhaps you should review:
It would be worthwhile trying something yourself, then coming back with a question...
Thanks!
The only good way is to store the values each time they are changed. The best is storing in EEPROM like 24LC64. 1,000,000 erase/write cycles. Writing every hour gives then 114 years.
I don't have say that the 24LC64 is the best choice. I have say that storing in EEPROM is better then using intern semi EEPROM with less write cycles. The 24LC64 was an example.
Thanks for the answers, yesterday i opened the examples of EEPROM which included in Arduino IDE, i make some changes on my code based on those examples and i managed to unplug from power and keep the numbers(cant figure out how the things works about variables ) and i am still facing some problems as
at first running display the number 256 i think.
when change number it is flickering(before include EERPOM the transition was smooth)
i attach the code again.. if you have any advise to be better, i will preciate it!