Pages: [1]   Go Down
Author Topic: Numeric keypad to HH:MM:SS & millis  (Read 643 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?   
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 27363
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Pages: [1]   Go Up
Jump to: