I haven't written any code in a long time, I started with Pascal in Highschool and A little Basic in College, so I am both behind and rusty. I started this with a 1000+ word outline and ran it through an AI code generator. I then worked through it to get it to this point(almost there....)
The point of this is to build a variable timer for a sprinkler system. It will have up to 8 zones, the user can either input time as seconds or minutes between 1-254(000 bypasses zone). Times are saved to eeprom, so if the user loses power the system will automatically start without needing to re-enter info.
I have it "working" to a point. The runSequence() pauses for the desired time, but if a user isn't "holding" the "A" key at the correct moment, it doesn't reset. Ideally it would be done as a thread so the "A" key can be pressed at anytime while the runSequence() is working, but alternatively, I have also accepted that I may have to add a countdown with "If timenow != 0
pause(1000)
timenow = (timenow - 1000)
or something along those lines to allow the function to check for "A" every second.
I have tried but haven't been successful in a day or two so I am asking for a little assistance...
There are many sprinkler projects posted on this forum, and several of them should meet your needs. A quick search will save you time compared to experimenting on your own. Try searching for "Arduino Sprinkler" on DuckDuckGo for some good starting points.
Since we can't see your code because you didn't post it. I will take a wild guess you have delay statements, but no millis and don;t know what a state machine is. All that and more are in the tutorials plus how to effectively use the forum.
I need it to save the times through a power loss, the person I'm building this for wants to switch it on/off, and i assume he doesn't want to have to re-enter the times unless something actually needs to change.
Yes, thats the part im having trouble with, as is, it pauses for the desired ammount of time for each "zone".
If a person presses "A" then it goes through the setup again allowing the times to change. The issue I am trying to figure out is how to get it to accept the keypad input while it is paused... as is, it only checks the keypad input before and after the pause, which can be up to 254 minutes, making it pretty much useless....
I thought about adding a countdown display, and using a 1 second pause instead of the pause for the entire time, so a person only has to hold it for a second or two before it goes back to "setup", but that is where i got lost.
I am going to study your code today, but I want you to study the tutorial on 'state machines', and 'doing many things at once'. If you can't find the totorials, let me know and I will give you the link.
I also want you to stop using i as a loop variable, give it a proper descriptive name. The other thing you need to do is to forget what you have been going in cirles about, you are only digging the hole deeper.
CLUE: the main loop should check the keypad first, only then go on to the other tasks. Give me a couple hours to verify what I think this (expletive deleted) code is doing and I will get back to you, but let me know the link to the two programing concepts I mentioned as soon as you find them so I can make sure they are the titorials and not some other post.
Try this link, I could not think of it when I originally answered. https://opensprinkler.com/ This has been around for many years and the code (several versions) is available on line as is the schematic. Stay dry!
I can't look at your code just now, but when I do the first step will be to apply the IDE Autoformat tool.
Which I suggest you do, even if you have to go through all the trouble of copying it out of the wokwi, putting it in an IDE sketch and carrying it back to the wokwi. It does no either need to compile or run int the IDE, it can get the Autoformat just fine.
Which really is not trouble be at all, shouldn't take a minute.
It won't fix thing like this
for (int i = 0; i < 8; i++) {
RelayTime[i] = EEPROM.read(i + 1);
};
that's a harmless but unnecessary semicolon afterthe closing brace. Harmless but unnecessary ink is distracting; if it is t meant to add clarity, like parentheses to ake your intention clear even if the compi,er woukd have done without them is one case.