Asked — Edited

3 Ultrasonic Sensors On The Ez-B Ver 3 And Ver 4 Boards?

I want to be able to use 3 of the Ultrasonic sensors at once on an EZB ver3. Is this possible? How would I do it in the ARC software? I only see the ability to use one now, or am I over looking something.

Instead of using a servo to scan, I want to be able to have one Ultrasonic sensor point forward, and the other 2 at 60 degree angles on the left and right of the one pointing forward.

Am I overlooking the ability to do this or is it not possible to use more than one Ping Sensor?




Upgrade to ARC Pro

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


Yes you can... you just use more ports and additional ping controls... very easy... You can also use scripts to replace the native sweeping ping control...


Great. Thanks Richard for the quick reply. I essentially would want a robot to turn and drive towards the ping reading with the highest number (obstacle avoidance). I have worked a little with the scripts in ARC and I am comfortable with making script calls to the open ARC windows and the buttons (functions) within them, but I am wondering if anyone has some sample code or an ARC file using 3 Ping Sensors out there. Thanks again Richard.

United Kingdom

You don't even need to script it.

If you want to use them for collision detection just add 3 Collision Detection controls, configure the ports and the minimum distances and let it roll.

This will just stop the movement though, it will not avoid anything.

You could adapt my Ping Roam script to use 3 sensors and remove the servo. The scripts are commented (in fact in the one I linked to I even included my hand written notes on my original Ping Roam script).

If my script looks like it's what you want to use but with 3 sensors but you struggle to make the changes I'll gladly update it, it's something I need to do for Melvin at some point anyway but with one thing or another I've not gotten around to it.


Wow Rich. Fantastic. Thanks so much for the advice and program. I will give it a go and post results. Thanks again.



@Rich . Hi Rich. I happen to have the perfect platform (IMO), for testing out many EZ-Robot modules. It's called Multiplo. It was a Kickstarter Robot Kit. It came with an Arduino Brain and HBridge on board called the DuinoBot. I built the 3 Wheeled Robot with Arm and Gripper.


User-inserted image

As soon as I received an EZB 3, I immediately replaced the DuinoBot brain, with the EZB and the 2.5 Amp Motor Controller HBridge, to control the existing 2 servo Arm/Gripper and the 2 Motors for the front I could do cool DJ Sures actions like below!

After I received Richard R's and your response today, I quickly prototyped a 3 Ping Sensor Array Rig and mounted it on the Multiplo Robot.


User-inserted image

After arriving home I just wired all 3 Ping Sensors up and they are on the following pins:

Middle Ping Sensor Trigger D2 Echo D4

Right (Robot's Perspective) Ping Sensor Trigger D5 Echo D6

Left (Robot's Perspective) Ping Sensor Trigger D9 Echo D10

I downloaded your Ping Roam 1.2.0 Alpha Code and Merged the Script Manager with my existing Robot Code. Went smooth.

After looking at your PingRoam Script Manager window and then each script inside, I got a little confused as to how I would integrate a 3 Ping Sensor array and remove the servo code so that it just uses the left and right Ping Sensors instead of a servo to sweep. Basically the syntax.

Thanks for all of your input Rich. This code looks amazing. Going to try and play with just using the middle Ping sensor right now and removing the servo code if I can do it correctly.


@Rich . Ok after looking into your code a little further I see that the GetPing script is where I can add additional sensors. Excellent job on your #Comments in your code. I will give it a go.

*Quick Note. I noticed that the name of the script SweepCentre is spelled "C-E-N-T-R-E", but the servo call in the Roam script has it spelled "C-E-N-T-E-R".

actual code

Servo(D2, $sweepcenter)

$sweepcenter is making a string call to the script SweepCentre correct, or am I not understanding it correctly?




ARC is not like C code for arduino... $sweepcenter in the context of your above example is just a variable (or constant)'s not a call to a function... I myself am currently learning arduino and C.. ARC is far easier than Arduino C.... ARC code is almost like Basic (remember that ancient language) but way more powerful.... I haven't looked at Rich's code, but for simplicity sake you can use a repeatuntil loop that checks 3 pings with if statements....

Hang in there, you'll get the hang of ARC.... Simplicity, yet powerful.... all in one...


will he have to worry about a +5v regulator? or a 3.3? Cause it is going to get the voltage off of the ezb4?


He would if he was using a EZB4, however he is using a V3 board...


ok, I saw where the title says V3 AND V4. That's why I asked.


Thanks guys. Much appreciated.

United Kingdom

I tried replying earlier but have been having a nightmare day today!..

With the center/centre thing, it may well be possible I made a typo since we spell it differently over here to over there, however I use both spellings on many occasions depending on what it's for so can get a bit mixed up.

As Richard pointed out, the $SweepCentre is the variable. This is calculated from the $SweepMax - $SweepMin / 2 at the start of the script. $SweepMax and $SweepMin are variables at the start which makes customising the script easier.

So basically, where a command uses $SweepCentre for a value it's really using the value. For instance, if SweepMin is 1 and SweepMax is 180, (180-1)/2 = 90 (rounded up).

I will admit, I haven't properly tested the latest ping roam script since I still don't have anything suitable to test with or a suitable environment to do the tests so it may have errors, but I have done some quick tests and it didn't flag anything up.

Changing the Get Ping script should allow you to get all 3 sensors at the same time, you can also remove any calls for the sweeping of the servo. In fact, running 3 sensors rather than 1 on a servo will greatly reduce the amount of script needed and give much more accurate results as there would be no delay in the robot knowing the distance on the left, the distance on the right and the distance straight ahead.


HI, @RIch

Can't thank you enough for this awesome scripting. I was at my local makerspace this evening,, and I had our makerspace coding expert Dan Wakefield take a look at the ARC and the PingRoam code. I showed him how ARC worked and the powerful scripting and within 5 minutes of showing him ARC, Rich's PingRoam Code, and my Project Goal... he understood it and off we went to making the code work for a 3 Ping Sensor Array. After an hour of coding and testing we had success!

# Ping Object Avoidance
# Using 3 Ultra Sonic Ping Sensors for avoidance through a corridor or hallway
# ORIGINAL Version 1.2.0 by Rich Pyke
# THIS Version 1.3 (for 3 Ping Sensor Arrays and no servo sweeps)
# Updated: 2014.7.25 by Dan Wakefield and Phillip Briski

Ping Roam v1.3 for 3 Ping Sensor Array Code here -> PingRoamv1.3Alph3PingSensoryArray.ezb

3 Ping Sensor Array "Ping Drive" (Corridor Driving)

This is a 3 Ping Sensor Array mounted on the Multiplo 3 Wheeled Robot. The brain is an EZB ver 3 board and the code is running from the ARC PC Application.

The code base is from Rich Pyke's Ping Roam 1.2.0 Alpha ARC FIle.

The code was edited by Dan Wakefield and Phillip Briski to remove the servo code for sweep and replace the after sweep ping values with the Ping values form the left, right, and middle Ping Sensors.

The goal was to get the robot to move through a hall or corridor and keep itself as close to the middle of the corridor as possible.

This was essentially achieved by allowing the "MoveLeft" and "MoveRIght" scripts to play off each other in "less than" values for the Right or Left Ping Sensors.

The Avoidance Script was highly edited to achieve the goal. One main thing edited in the Avoidance script was setting the $maxdistance value and creation of a $dontmove variable which would not allow the robot to move forward if the set value (can be adjusted in Start Script) of less than 15 was that of the middle Ping Sensor. This then allows the MoveRight and MoveLeft commands to turn towards the greater ping value from the left and right sensors.

Minor adjustments to sleep times were added to smooth turning and forward movement.

Thanks again @Rich, @Richard R, and everyone in the EZ-Robot Community. This has to be the most helpful forum I have ever experienced. Glad to be a part of it.




Great news Phil.... Wait until you dig deeper into ARC and really see just how powerful ARC truly is....:)

United Kingdom

That's awesome dude, and I'm happy to help and guide anyone:)

As Richard R says, wait until you dig deeper. ARC is pretty darn remarkable and extremely powerful but also so easy to use as I am sure you have realised.