Let's Make Robots!

arduino timer

I have an arduino severino s3v3, atmeg168  and  a  hcsr  ultrasonic sensor.

what i want is to start the timer when HCSR get an obstruction.

and stop it when the obstruction is clear.

I know the algorithm.bt I'm confused about using the proper function for counting time.

     (also after counting the time the function to reset it.)

Thanx in advance