Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!


Ultrasonic Distance

How to add the Ultrasonic Distance robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Ultrasonic Distance category tab.
  5. Press the Ultrasonic Distance icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Ultrasonic Distance robot skill.

How to use the Ultrasonic Distance robot skill

Ultrasonic sensors use sonar (sound navigation ranging) to determine the distance to an object or wall, the same way that some animals like bats and dolphins do. They offer excellent range and accuracy in an easy-to-use package. Their operation is not affected by sunlight or black materials, as infrared sensors are. However, they do have trouble with some soft materials, the sonar echo works ideally when bouncing off hard surfaces.

When an HC-SR04 or equivalent Ultrasonic Distance Sensor is connected to an EZB, this skill will display the distance of a detected object/wall in front of the sensor. This skill does not cause a robot to steer or avoid obstacles; it merely displays a distance value. For object avoidance and steering use the Radar skill.

This skill is integrated with scripting and will update when GetPing() is called (with matching port configured) and the PAUSE checkbox is checked. That way you can have this skill on your project but it won't use any communication resources unless it's called from a script with GetPing(). What this means is you can leave the PAUSED checkbox checked, and this skill 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 unit is required, use a tape measure to identify the distance value.

Main Window

1. Ultrasonic Distance Value
This is a value between 0-255 that corresponds to the detected distance being sent by the ultrasonic sensor.

2. Bar Display
Displays a visual representation of the detected ultrasonic distance value.

3. Pause Checkbox
This checkbox pauses the capture of the ultrasonic distance value.


1. Title Field
This field contains the title of the skill. You can change it if you'd like. *Note: Changing the title will also change the title in the controlCommand() associated with this skill.

2. Board Index Drop-down
Select the EZB index number that your ultrasonic sensor is connected to.

3. Trigger & Echo Port Drop-downs
Select the digital port that your ultrasonic trigger wire is connected to. Also, select the digital port that your ultrasonic echo wire is connected to. *Note: This port must be the same as the trigger port when using a 3-wire Ultrasonic sensor.

4. Interval Drop-down
This drop-down selects the interval rate in milliseconds that the ultrasonic sensor will be sampled at. The range is 100-60000 milliseconds. The default setting is 250.

5. Variable & Multiplier
A variable will be set with the most recent distance value. This saves your code from having to call GetPing which adds needlessly to the communication channel.

The multiplier value will convert the raw distance value to a unit of measurement. For example, the default value of 1.25 will convert the distance into CM.

6. NMS (Navigation Messaging System)
The distance data can optionally be configured to push detected distances into the NMS (Level #3 Group #1) to be used by navigation robot skills, such as The Navigator. Please read the NMS manual and question marks associated with the options for better detail.

Wiring Diagram

Ultrasonic Distance Sensors come in 2 versions. A 4-wire type with/without an inline voltage regulator and 3 wires with/without a built-in voltage regulator. If an Ultrasonic has a voltage regulator it will need +6V or greater Voltage input, if it doesn't it will need +5V.

3-wire Wiring (with built-in regulator)
  • Ground = Black wire to GND
  • Power = Red wire to Vin
  • Trigger/Echo = white wire to Digital pin
4-wire Wiring (with regulator)
  • Ground = Black wire from regulator to GND
  • Power = Red wire from regulator to Vin
  • Trigger = white wire to Digital pin
  • Echo = green wire to a second Digital pin

Fix Resolution

If you are using an EZ-Robot ultrasonic distance sensor, there may be false positives from the ping sound echoing within the casing. It is easy to fix with a few cotton balls inserted in the case around the sensors. Watch this video for detailed instructions.

Tech Details


You will need an EZB I/O Controller and a Ultrasonic Sensor to use this skill.


Synthiam has a ultrasonic hardware reference design here.


Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

#2   — Edited
:) This control is used for debug purposes only and not necessary for operating. Your scripts that call GetPing() do not need that control added
ah i have to read GetPing()

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

I'll modify ARC to allow you to have ultrasonic distance and call getping() at the same time.
i wanted to use that to get more visual aspects in my ARC.

thank you dj
United Kingdom
Hi Guys, 

so todays issue on the list of 99999 things to sort is i cant for the life of me get a sonar sensor to work. I am using a arduino leonardo as the ez-b , the sonar is connected to pin 10 trig / pin 11 echo , its powered externally and tried of the board with common earth using 5 and 6v in ARC i set sonar distance to read for the pins and i get nothing except N/A and no reading ?  tried 5 diferent sensors as came in pack of 5 no results at all, its unpaused as well .. help :-) 

Review the debug log and the message will be displayed about the latte panda firmware not supporting the ping sensor. It's easy to add though, i can do it for you if you're not familiar with arduino. I'll have time to do that early this week. I'll let you know when it's done:)
United Kingdom
#9   — Edited
That would be great m8 , i am using a seperate arduino leonardo though , not the on board one does that make a diference ? i do have a microbit woud lthat support it just for testing ?
United Kingdom
Ok, i may jusy wait till you sort the leonardo firmware if thats ok , can you advise when its sorted plz
Ya my Latte Panda is also half Leonardo along with Win10 but I have yet to use it for any Arduino programs The Win10 is just so much easier to use with all my Io Tiny controllers where all sensors work instantly and programming is done in minutes instead of days with Arduino coding.
United Kingdom
Any updates on the firmware to get sonars working on the arduino yet ? pretty please :-)

I published the changes in the next build so it will go out when the build is published. I think it’s schedule for early next week