Behavior Control
Help Index

Ultrasonic Distance

How To Add This Control To Your Project

  1. Load the most recent release of EZ-Builder
  2. Press the Project tab from the top menu bar of EZ-Builder
  3. Press Add Control from the button ribbon bar of EZ-Builder
  4. Choose the Ultrasonic Distance category tab
  5. Press the Ultrasonic Distance icon to add the control to your project

The HC-SR04 or Ultrasonic Distance Sensor can be connected to two digital pins. This control will display the distance in inches detected by sensor. This sensor is also called an Ultrasonic Ping sensor, by parallax, or Ultrasonic Distance. The most popular model number of this sensor is HC-SRO4, such as the Ultrasonic Distance Sensor

EZ-Script Integration

This control is integrated with EZ-Script and will update when GetPing() is called and the port configuration matches that of this control and the PAUSE checkbox is checked. That way you can have this control on your project but it won't use any communication resources unless it's called from EZ-Script with GetPing(). What this means is you can leave the PAUSED checkbox checked, and this control will be updated when GetPing() is called.

It's worth noting that the distance displayed is not a unit of CM or Inches. The distance value is an arbitrary number that is related to the type of sensor, voltage, detected material, and temperature. If a specific distance is required, use a tape measure to identify the distance value.

The EZ-Robot Ultrasonic Distance Sensor comes in 2 versions. The first version, sold until February 10, 2017 uses 4 wires and an inline voltage regulator. The second version, available after February 10, 2017 uses 3 wires with a built-in voltage regulator in the plastic shell. The second version is updated and requires only a single plug to the EZ-B v4. We cover the installation of both sensor versions below...

Version 2

This is the 3 wire version #2 (most recent) of the EZ-Robot Ultrasonic Distance Sensor. This version uses only 3 wires contained within a single connector. You may connect this version to any of the EZ-B v4 digital ports (D0-D23). In EZ-Builder, the values for both Ping and Echo can be selected for the same port.


Version 1

This is the 4 wire version (older) of the EZ-Robot Ultrasonic Distance Sensor. This version has an inline voltage regulator and 4 separate wires. This version is a little more complex than the recent Version 2, due to separate wires and the inline voltage regulator.

ultrasonic distance sensor pin out

  • Ground = Black wire from regulator PCB to D21 black pin
  • Power = Red wire from regulator PCB to D21 red pin
  • Trigger = white wire to D21 White pin
  • Echo = green wire to D22 White pin

Ultrasonic sensor connected to ez-b
DJ Sures
February 1 — Updated February 1
:) This control is used for debug purposes only and not necessary for operating. Your scripts that call GetPing() do not need that control added
February 1
ah i have to read GetPing()

February 1
$x = GetPing(d22,d22) this doesn unpause the ultrasonic ? i am confused.
i use the version 2 ping sensor.
DJ Sures
February 1
GetPing() doesn't need the ultrasonic control at all. When you call GetPing(), it's separate than the ultrasonic control.

I'll modify EZ-Builder to allow you to have ultrasonic distance and call getping() at the same time.
February 1
i wanted to use that to get more visual aspects in my ez builder.

thank you dj