Here is the scenario: The sensor is pointed at a black lightly padded wall. And the sensor is secured to an object that oscillates toward and away from the wall. What is the best sensor to use to keep track of distance from the wall within the range of 4 inches to 9 feet from the wall or 0 - 3 meters? The sensor must be able to sample accurately within a few inches at a rate of at least 5 Hz.

I have tried using the lv-ez1 ultrasonic sensor, but this only has a reliable range of 1-3 feet at a rate of 5 Hz.

  • \$\begingroup\$ What's the amplitude of the oscillation and is it sinusoidal? \$\endgroup\$
    – EM Fields
    Jun 27, 2015 at 6:44

1 Answer 1


Your problem is made a little bit more difficult by your selection of a surface that reflects neither IR nor ultrasound well.

Accelerometers are almost totally useless for position feedback.

We could really do with some more information about your setup - it looks like you've tried to abstract away the details to make it simpler to answer, but background information is often helpful.

Possible solutions include:

  • A camera above your "object" tracking it with OpenCV or similar. (Unclear on whether this is feasible)
  • If there is a wall behind your object which is not black and soft, measure the distance from this wall instead
  • If your "object" has USB support then an optical mouse dragged over the ground will give you fairly accurate odometry
  • If your object is on wheels, put an encoder on the wheels to measure their rotation
  • A pattern of alternating black/white stripes on the floor which can be measured with a pair of photosensors (one in front of the other, closer spaced than the stripe width) to determine movement

Which solution is best for you depends on the specifics of your project.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.