

#MULTIPLE COUNTDOWN TIMERS CODE#
Really appreciate any help or advice anyone can give in terms of code implementation, approach or libraries. Priority here is the non-failure of the timers and would be willing to trade off some accuracy (in the customers favour) to achieve this. I could use a RTC as well and set actual finish times, but concerned this is another thing to go wrong and could cause incorrect timing if it failed. I have seen lots of different implementations of timers but they all tend to be counting up, using Delays or not working for multiple timers in parallel. I am a bit concerned about writing too much to the EEPROM so would be happy to write the countdown state/time remaining maybe every minute? I also need to be able to handle new customers setting new timers (via interrupt from Coin acceptor pulse) and displaying things on LCD at the same time as not compromising the ongoing timers.

I am currently doing the timer by taking the Millis() when the button is pressed, creating FinishTime in Millis by adding on the hours the user selected and then checking in the loop if the current Millis() is between these 2 numbers (then relay ON, otherwise OFF).īut this approach will not survive resets and is probably not scalable to 8+ concurrent timers.

I have a basic working implementation with an Uno, a coin acceptor to add credits of hours, a switch to select the device and a single relay. Have ability to survive power outage/reset and continue.Timers must survive reboot/power outage and continue counting down.Timers must be robust and accurate (~1min in 24hours).Multiple customers can use multiple devices at the same time with different length timers.Relay switches off when countdown (hours) are over.Relay switches on for device selected and countdown starts.Customer chooses device they want to use this on (8-16 devices).Customer selects time period they want in hours (1, 3, 6, 9, 12, 24etc).I am currently working on a project and wanted to get some advice on the best type of code implementation.
