Programming a Basic Wristwatch

Hey guys,

So I’m attempting to make a basic digital wristwatch that I will eventually turn into a sailing timer (thats another story), and I’ve currently managed to make it show the time using 4 multiplexed seven segment displays by implementing the millis() function. I’ve run into some problems and wasn’t sure if anyone could offer help.

I’m currently testing this on an arduino uno on a breadboard with four seven segment displays and a set of switches.

The fundamental problem:

Using millis() sucks because it cant be reset. I want to have the typical clock/countdown timer/chronograph functionality, but I really cant figure out how to do it with millis() so I found this: http://arduino.cc/playground/Code/Timer1 but frankly I dont know how to use it for what I want.

Other Issues

Changing mode: I’m trying to just write a program that will cycle through a few different arbitrary modes (ie one showing 0000 on the display) while keeping the time in the first mode intact. I can’t do it well…

Distinguishing from holding and tapping a button: a typical wristwatch adds a whole different set of commands by holding a button versus tapping it. this would be easy if I could use delay() but I cant because It ruins my multiplexer code and stops the display…

Any tips would be very helpful, as I’ve been scratching my head. This is my first real project…

-Jake

Code:

I decided to go about making this by first making two seperate programs, one that just tells the time and one that counts down from five minutes.
I’ve attached those two programs… Clock Prototype counters is just a functional clock that can be set using some switches, Clock Prototype Timer is the timer part, which counts down from 5 minutes, badly… It jitters on some digits and once it reaches 4 minutes it stops working and shows all 0’s

If you want to see how someone better than me made a basic wristwatch, heres the code for the BigTime kit from Sparkfun, which I will eventually be hacking for this:
https://github.com/sparkfun/BigTime/blob/master/BigTime.ino

Clock_Prototype_Timer.ino (3.11 KB)

CLOCK_Prototype_Counters.ino (4.76 KB)

Using millis() sucks because it cant be reset.

“I’ll see you in five minutes”.

Do you reset your wristwatch?

Hey AWOL sorry that might have been vauge. Millis() counts the number of milliseconds since the arduino was turned on. It would be convenient to have something that counts the number of seconds since it was cast (ie when I hit the start button on the timer)

Millis() counts the number of milliseconds since the arduino was turned on. It would be convenient to have something that counts the number of seconds since it was cast

There were, at last count, exactly 1000 milliseconds in a second.

Coincidence? I think not.

jakespracher: Hey AWOL sorry that might have been vauge. Millis() counts the number of milliseconds since the arduino was turned on. It would be convenient to have something that counts the number of seconds since it was cast (ie when I hit the start button on the timer)

All that is just proper software commands and math operators. millis() automatically provides you with a proper heart beat, you just must apply it to your task. Look at the IDE's example sketch BinkWithoutDelay for an example of how to make something happen each and every second, not unlike what you need.

Lefty

jakespracher: Hey AWOL sorry that might have been vauge. Millis() counts the number of milliseconds since the arduino was turned on. It would be convenient to have something that counts the number of seconds since it was cast (ie when I hit the start button on the timer)

Record the time when you start it. Look at the time now. Subtract one from the other. That is the amount of time that has elapsed.

Nick,

Yeah I figured as much, that was just getting really complicated. Its hard enough to just get the thing to count down 5 minutes from when the arduino turned on never mind accounting for the time millis() started in that whole mess. I guess I was hoping someone would tell me "you're doing this the hard way, here's an easier way" but I suppose thats not the case. I'll just keep at it. If anyone sees a simpler way to do this that would be awesome

Its hard enough to just get the thing to count down 5 minutes from when the arduino turned on never mind accounting for the time millis() started in that whole mess.

It sounds to me like you're over-thinking this. A 32 bit subtraction in the microcontroller can be performed many tens of thousands of times a second.