Some that records time between button press

I want to create some thing that records the time between buutton presses, like a watch. Can anyone guide me to what this is called?
Thank You,

“stop watch”


(more detailed answer coming when I find a reference I am looking for!)

There is a stopwatch / lap timer for swimming that might help show you some of the core concepts,, but here’s a little more information that might mean you can capture this yourself.

You need to capture what time the button was pressed. So you need to track the “state” of at least the first and second presses. Once you have those sorted, you just calculate the difference.

Since I know you’ve just got a Gadgeteer board, I’d suggest the best / only way to deal with this is to capture button presses in an event handler. You can look at the Gadgeteer camera project to see the actual method of performing an action in the handler, and a simple way of tracking your needs is to figure out what the “state” is (ie whether it’s an odd numbered press, so it’s the “start”, or an even numbered press “finish”), and update the global variables (and display the difference if it was the “stop”).

here’s some code I have

ClosedSensor = new InterruptPort(ClosedButtonPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
ClosedSensor.OnInterrupt += new NativeEventHandler(DoorSensor_Capture);

void DoorSensor_Capture(uint port, uint state, DateTime time)
        {  // do stuff

you can see the “time” value the handler provides, that’s when the event occurred - thats what you want to capture and use to calculate your differences.

Why not using DateTime.Now. You log it each time you press button, make a substraction and you will obtain your value.

If you use an interrupt port for capturing the button press, the exact time of the depression is passed to your interrupt handler.

For exact timing, you have to be aware of the effect of the Glitch Filter if is turned on, or multiple bounces if it is not.

Sorry for taking a long time to reply.
I was at school.
Thank You,