Is it possible to set a timer related to a sensor with arduino?

Hi everyone,

Is it possible with Arduino to count the amount of time a certain value is given by a sensor?

In example, I would like to count the time my ultrasonic sensor is detecting an object closer than 2 meters so a timer should start counting when an object comes closer than 2 meters.
Could you give me some intructions to begin with, please?

Thanks in advance!

Yes, have a look at millis() Gives you all you need.

septillion:
Yes, have a look at millis() Gives you all you need.

Great! That should work. Thanks!!