How to make a Ultrasonic Sensor work for a specific amount of time

Hi, i'm new to the whole arduino scene. Currently i've been working with a ultrasonic sensor, i wanted to make it work for an example for about 2 secs and then stop receiving signals. To make it work again, i would simply take the object out of the front of the sensor and put it back in, in order to make it work. Can someone teach me how to do this in code?

Your whole premise is not possible. How would any program know if you removed a reflective object if the ultrasonic sensor was not currently in operation. This is requiring magic of some sort.
Paul

It sounds like you want each new object to be acted on for two seconds. To do that, you would record the time when the state goes from Object Not Present to Object Present. If object is present and it has been longer than two seconds since the object was first present, ignore it. Do you want the object to be acted on for two seconds even if the object is removed before the two seconds is up?

Hello
Describe in simple words how the function should work and do it very simply.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.