Getting Ultrasonic sensor to stop after object moves backwards

Help needed,

For a physics project I am trying to use the Ultrasonic sensor (HC-SR04) to measure the distance between itself and a moving cart to measure frictional dissipation. I want to programme so that once the object start to move backwards (as it is on a ramp) it ceases the programme and displays that distance on an lcd.

If anybody has any idea's, it would be a great deal helpful.

A Time of Flight Distance Sensor will give better results.

Example:

1 Like

Thanks, won't come in time but if I order it and don't live near any electronics shops. Have to do the best with what I've got.

First figure out how to determine that moment.

When that moment is reached, set a logical flag (a state variable) that directs the program to stop measuring distance and to perform other desired actions.

See the Arduino State Machine example.

Yeah that's the way to go, just trying to find a way to describe. Is there any way you could have a clause if object distance > than previously recorded distance == project value to lcd.

Yes, that is possible.

what would the syntax look like?

If you want help with code, post the code you have, using code tags, and explain where you are having problems with it.

For instructions see the "How to get the best out of the forum" post, linked at the head of every forum category.

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