Go Down

Topic: Numeric keypad to HH:MM:SS & millis (Read 675 times) previous topic - next topic

polepole

I'd like to use a numeric keypad to have the user input a time (in HH:MM:SS format), and then be able to set a timer based on that input. The problem is that the user, if they want to enter 1m30s, won't be hitting 0-0-0-1-3-0. They'll just hit 1-3-0.

(to summarize: when user hits 1, display will show: 00:00:01. When they hit 3, it'll show: 00:00:13. When they hit 0, it'll show: 00:01:30.)

So how do I transpose the input into something usable? I can figure out how to display the input on the screen by sliding each number left one after a keypress, I just can't figure out how to get the corresponding millis out of it.

I've thought about dropping each keypress into it's own variable as there are only 6 total (keypress1 = 1, etc.), but I still can't figure out how to manipulate the numbers.

Thoughts? 

CrossRoads

Start with the keypad tutorial and make reading of the keypad work.
What is your plan to determine when time entry is complete?
Millis (for counting down?) can then be determined by simple math:
tens_hours + ones_hours x 60 minutes/hour x 60 seconds/minute x 1000 mS/Sec =  hours_milliseconds
tens_minutes + ones_minutes x 60 seconds/minute x 1000 mS/Sec  = minutes_milliseconds
tens_seconds + one_seconds x 1000 mS/Sec  = seconds_milliseconds
add 'em up.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up