#### Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Resolved by Rich!

## Ultrasonic Sensor And Sharp Ir Sensor

Looking for some help / sample of a script combining the 2 for navigation. This is on a omnibot 5402. I have the IR sensor mounted above his speaker. The ultra sonic is on a sweeping servo right above the IR sensor. I tried playing with Richs ping roam script and he just spins in circles. I would be grateful for any help with this.

Get access to the latest features and updates with ARC Early Access edition. You'll have everything that's needed to unleash your robot's potential!

Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
United Kingdom
#1
The thing to remember is ultrasonic measures how far away something is (i.e. the greater the distance the larger the result) and IR measures how close something is (i.e. the closer the object the higher the number).

To get the IR data from the sensor, assuming it's connected to ADC0, you would use a GetACD() command i.e.
`Code:\$IRSensor = GetADC(ADC0)`

To get the ping you use
`Code:\$PingSensor = GetPing(D0, D1)`

Then use those within an if
i.e.
`Code:IF(\$IRSensor > 200 OR \$PingSensor < 100) Say("There is an object in my path")EndIF`
#2
@ Rich how would I intergrate this into your ping roam script?
United Kingdom
#3
Edit the "GetPing" script in the script manager so it also fetches the IR reading, so adding in something like this;
`Code:\$IRdistance = GetADC(ADC0)`
`Code:# Check the current distance against the max allowed distanceIF (\$currentdistance <= \$maxdistance OR \$IRdistance > \$maxirdistance) # If the current distance is below the max distance start avoiding CONTROLCOMMAND("PingRoam", SCRIPTSTARTWAIT, "Avoidance")ENDIF`