Thursday, January 3, 2019

Maker Project - Work out Timer

So I wanted to make a timer to help me work out, but I figured I could make it myself using an Arduino Uno and a 4 digit 7 segment display (digital number display).

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:
  1. 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.
  2. 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.
  3. 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.
  1. I added a green light for the workout timer - countgo
  2. I added a red light for the rest timer - countrest
  3. Length of timers
    1. n is the length of the workout timer
    2. m is the length of the rest timer
  4. Order of code
    1. Start with the "m" rest
      1. countrest - millis() < m
      2. translation - run the rest timer until it reaches zero
    2. Do "n seconds of workout
      1. countgo - millis () >= m && (and) millis < n + m 
      2. 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.
    3. Restart the loop.
Here is the code if you want it: