Pages: 1 [2]   Go Down
Author Topic: Saving values to eeprom  (Read 1120 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 54
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I understand. My next question would be, how would I go about writing the the saved values when powering on the arduino after its been off? Or is how I have it correct besides the changes to be made in the buffer?

Speaking of buffer, here's something I was working on throughout most the nite before finally getting the bugs out earlier today. I added another case to my program to simply turn on/off the red led in my RGB. I was able to turn it on on first attempt with no problem, however it would only turn off on the 4th button press. (I have the button setup as a toggle switch)
ex. Press button- red light turns on
     Press button 2nd time to turn off- nothing
     Press button 3rd time- light is already on so no change obviously
     Press button 4th time- finally it turns off

I tried every combination of Serial.read(), Serial.flush(), Serial.peek() and any other combo that mite work within the case and nothing. Finally instead of having of the app send only 1byte(3) to turn the light off, I changed it to  send 3bytes(9,3,9) and FINALLY it worked properly lol. I believe it was an issue with the buffer, but I cannot understand what exactly. Here's the code..
Code:
  case 'R':
   digitalWrite(redpin2, HIGH);
   break;
  case 3:
   digitalWrite(redpin2, LOW);
   break;
Sending the 'R' - no problems there. Sending only 1byte(3) gave me the headache I just explained. Sending (9,3,9) and it works perfect, which Im glad, but Im not sure why though. If you have any idea, I'd really like to know, this thing was driving me crazy lol
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My next question would be, how would I go about writing the the saved values when powering on the arduino after its been off?
Writing what values? You seem to not understand that EEPROM is to save data so that you can READ it after a power down/reset.
Logged

Pages: 1 [2]   Go Up
Jump to: