Here is what I wanted: I wanted a timer that would count down from a time (30 seconds) for work out, followed by a rest time (10 seconds). Then I wanted it to repeat until I was done. Here are some resources that I used to gather information.
Resources:
- Timer with Reset button - Copied the code from here. this helped me understand the code as well as the plugs on the display - check out the notebook paper image. This helped me get the connections and a timer set up, but it counts down and stops. Will restart if you press the button. Thank you RishiSadana.
- Description of millis() function and what that means. This is what I used to set the parameter for which function to run in my code. Thank you Arduino Project.
- How I learned to programmatically reset the Arduino (I used the 2nd method on this website). Thank you Syed Zain Nasir.
Here is how I altered the code from resource #1. I have annotated it, but here are the changes that I made.
- I added a green light for the workout timer - countgo
- I added a red light for the rest timer - countrest
- Length of timers
- n is the length of the workout timer
- m is the length of the rest timer
- Order of code
- Start with the "m" rest
- countrest - millis() < m
- translation - run the rest timer until it reaches zero
- Do "n seconds of workout
- countgo - millis () >= m && (and) millis < n + m
- translation - time is between 10 and 40 seconds - I just wrote it this way so I could change the rest and workout time if I wanted.
- Restart the loop.