Interfacing and Programming Ultrasonic Sensors – Tutorials and Resources

It is essential to give your robot eyes for preventing crashes. Ultrasonic sensors, also known as transducers, have a similar working system as a radar or sonar by interpreting the echoes of radio or sound waves generated by the sensor. In this way, a robot can detect obstacles and the distance to obstacles. In this article, we make an overview of most popular ultrasonic sensors used in robotic applications and tutorials to learn how to interface and programming these sensors in order to build robots.

The working principle of an ultrasonic sensor is simple and use high-frequency sound waves that are evaluated when the sensor received back the waves. To determine the distance between the robot and object, the sensor measure the elapsed time between sending and receiving the waves.

These sensors are ideal for measurement in different environments where measurements cannot be affected by the surface, material, light, dust, or other noises.

In robotics, ultrasonic sensors are used in a wide range of applications including here the measurement of distance, presence detection, or detect the position of an object.





HC-SR04 is one of the most popular ultrasonic sensors used in robotics by students and hobbyists to determine the distance from a robot to objects. It is available at a low-price, it is stable and has high accuracy. Working principle is similar to bats or dolphins, and its operation is not affected by sunlight or other noises.

HC-SR04 provides measurement function between 2 and 400 centimeters at a range accuracy of 3 millimeters. The HC-SR04 module hosts the ultrasonic transmitter, the receiver and control circuit.

Devantech SRF04/SRF05

Devantech SRF04

Devantech SRF04

Devantech series of ultrasonic sensors include two of the most popular sensors – SRF04 and SRF05. These two sensors are similar in features with a range between few centimeters to 4 meters. The resolution is around 3 centimeters.

Maxbotix LV-EZ0/EZ1/EZ3

Maxbotix LV-EZ1

Maxbotix LV-EZ1

Maxbotix release on the market a series of sensors with similar features and called EZ. These sensors has a resolution of 2.5 centimeters and can work on distance from few centimeters to more than 6 meters. The sensor has small sizes and is quality built.

  • LV-EZ1 – example how to programming the EZ1 sensor and display the values;
  • Distance Detection – tutorial with different programming code for Arduino and LV-MaxSonar EZ1;
  • All about Max Sonar EZ0 and Arduin – from this tutorial you can learn how to interface the EZ0 ultrasonic sensor with Arduino and how to programming in order to display the output values from sensor;
  • Arduino Uno R3 + MaxSonar EZ3 calibration – programming code for calibration and display the EZ3 ultrasonic sensor values interfaced with Arduino Uno board;

Vex Ultrasonic

Vex Ultrasonic

Vex Ultrasonic

Vex Ultrasonic is a powerful high-frequency sound wave sensor to measure distance between 3.8 centimeters and 290 centimeters.




Used for detection of moving or stationary objects, URM37 is another ultrasonic sensor with a resolution of only 1 centimeter. The sensor is designed for robotic applications with a detection range between 4 centimeters and 3 meters.

  • URM37 V3.2 Ultrasonic Sensor – guide from where you can learn how to interface and programming the URM 37 ultrasonic sensor and display the output of the sensor;
  • URM37 – programming code for robotic application where the URM37 sensor is used to detect the distance. In the code are handled error exceptions;

Parallax PING

Parallax PING

Parallax PING

PING is a low-cost and precise ultrasonic sensor used for measurements of moving or stationary objects. The sensor is designed to measure the distance between robot and object from a range between 2 centimeters and 3 meters.

Commerce Content is independent of articles and advertising, and if you buy something through our posts, I may get a small share of the sale.


Related Articles

8 comments » Write a comment

  1. if we place two HC-SRO4 sensors facing each other will they effect each other??

    please reply soon

    thank you in advance

    • Hello,

      Yes, two ultrasonic sensors could interfere and that way you have to wait until the first sensor ping to finish and then start to take reading for the second.

  2. I have a question about the parallax ultrasonic sensors. When using the VEX microcontroller, can you you the parallax “ping” sensors? If so, how are they wired?

    With the VEX ultrasonic, there are two sets of wires (input/output) that I plug into two digital ports and I have figured out how to program these to get my robot to work. But when I try to use the parallax, there is only one set and I’m not too sure how to program these.

    When I wire the parallax and plug it into digital port 1, the green light come on but I cannot get it to stop my robot. I then tried using a “Y” harness from one parallax and plug the two wires into ports 1 and 2….one lights up green, then other nothing. Then I tried to use 2 parallax sensors with their own wires plugging into ports 1 and 2. Ping in port 1 lights up but ping 2 in port 2 does not.

    The reason I ask is that I have about 30 parallax pings and very few VEX ultrasonic sensors.

    Any help or guidance would be greatly appreciated. Oh, I’m programming in robotC for VEX (not too sure if that makes a difference).

    Thank you for your time!


  3. Hi
    I’m doing water level controller project of residential water tank. i decided to measure the level of water using ultrasonic sensor with cheap rate. please suggest what type of ultra sonic sensor should i use ? Will ultra sonic sensor detect the water level ?

    • An ultrasonic sensor is both temperature and humidity dependent. I think that is not the best solution to measure the water level with an ultrasonic sensor, instead of this, you can try with an infrared proximity sensor

  4. So say we have something on a table outside with ultrasonic sensors around it. Which sensor would be best to use to detect it and how difficult would it be to program it to let us know that something is there or not?

  5. Hi there,
    I was wondering if it possible to use an ultrasonic sensor for just receiving ultrasonic signals?
    For example if an ultrasonic signal was emitted from a power source, how could I use these types of sensors to receive these signals and then plot them against time and amplitude?

Leave a Reply

Required fields are marked *.