AWOL:
Excellent way of burning out your EEPROM in a few minutes.
Put the code in setup, but I honestly can't see the point.
groundfungus:
If you put it in setup() it will run once and go on to loop().
Thank you both for replies. I need to save values between 0 and 6 where 0 means "do nothing" which are relevant only in current session and I need a little bit bigger storage.
I need to save values between 0 and 6 where 0 means "do nothing"
How much of this data is there in any one session ?
Even if you use EEPROM why do you need to set all of it to zero anyway ?
These numbers represent instructions. When Arduino reads 1, it will do one thing (spin two small DC motors in the same way to move forward), when 2, other thing (spin two small DC motors in the same way to move backwards). These instructions would be given through push-buttons. When it would read 0, it would mean that none of the buttons was pressed and that it sholud keep watching for button pushes.
So would you like to explain what you are trying to achieve with this code?
When none of the buttons is pressed, Arduino keeps watching for presses. If 1,2,3 or 4th button is pressed Arduino stores 1,2,3 or 4 in EEPROM and keeps doing that until 5th button is pressed. When that happens, Arduino from EEPROM reads values and according to them blinks LEDs. If during blinking fifth button is pressed again, blinking should stop and again wait for press of one of buttons (1,2,3,4). Storing in EEPROM starts from the first (0) adress. When turned ON arduino should delete old entries. Could it maybe be made simpler and there is a problem when I'm trying to stop blinking because of the delay(1000).
If yes, how to know how much is enough for RAM to suffice?
How do you know how much EEPROM you will use? The answer is the same.
As lots of us are saying there is absolutely no need to use EEPROM for this problem, which sounds quite convoluted to be anything but a piece of homework.
Arduino stores 1,2,3 or 4 in EEPROM and keeps doing that until 5th button is pressed
What does it store? is it the time it was pressed or simply the fact it was pressed?
Up to 50 instructions that is number of buttons presses.
then
byte presses[50];
will do it.
there is a problem when I'm trying to stop blinking because of the delay(1000).
Arduino stores 1,2,3 or 4 in EEPROM and keeps doing that until 5th button is pressed
What does it store? is it the time it was pressed or simply the fact it was pressed?
Up to 50 instructions that is number of buttons presses.
then
byte presses[50];
will do it.
there is a problem when I'm trying to stop blinking because of the delay(1000).
Then remove it.
On the beginning of the program I have made a function which returns if a button was pressed, it looks for raising edge. If I reomve delay LEDs will only blink and not stay ON for a second, which is my goal (look at the code).