I'm working on a code which uses millis to work with.
Here is what it does:
- Fixed intervals set for each action.
- Does an action, and adds its time to a variable.
- The loop constatly checking the variables, and when a variable reaches its intervals maximum time, it does an other action and adds its time to a variable.
Example: Turns on a LED, wait until given time, and then turns it off. The reason of millis of course to be able to do anything else during this switching.
I succesfully set everything, works good, BUT... Then it was time to add FEEDBACK, so I tried to add the print function to print out times remaining until each event to the serial port. I have different variables for turn off times and turn on times.
The feedback from event works great (says its on/off), but the time is constantly rising (I suppose thats how millis work) I set it to get a print from times every one second.
This is how it looks like: (LED on for 2 sec, off for 1 sec)
Time until LED turning on: 1 Time until LED turning on: 2 LED ON Time until LED turning off: 3 LED OFF Time until LED turning on: 4 Time until LED turning on: 5 .....
Do you guys have any idea how can I make it work like this:
Time until LED turning on: 2 Time until LED turning on: 1 LED ON Time until LED turning off: 1 LED OFF Time until LED turning on: 2 Time until LED turning on: 1 LED ON .....
Thank you in advance. Have a nice day :)