Congratulations Rich, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Question On Script Modification

Assistance Requested

Help Jayutmb with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Jayutmb claims to have checked these sources:

So I am looking to modify this script that was on the cloud (thanks btw), however I am a little stuck... I am using the sabertooth Movement Panel ... so the the speed and turn times ect... dont match up (i know it not currently set that way but the commands are totally different with sabertooth).. Any thoughts on how to modify this for sabertooth ?

# Ping Object Avoidance
# Using Ultra Sonic Ping Sensor on servo for avoidance
# Version 1.1.1

# Configuration Settings
# This script assumes the following ports;
# Trig Port = D0
# Echo Port = D1
# Sweep Servo = D2

# Adjust values below for movement control
$reverseturn = 1 # Reverse before turn? 0 = no, 1 = yes
$maxdistance = 30 # Change for maximum distance from object before avoiding in units
$boxedindistance = 20 # Change for maximum distance for boxed in detection
$turnamount = 500 # Change for how long to turn for in ms
$reverseamount = 500 # Change for how long to reverse for in ms (if applicable)
$movementspeed = 255 # Change for movement speed
$slowturn = 127 # Change for slow turn speed

# Adjust values below for sweep configuration
$sweepmin = 10 # Change for min limit
$sweepmax = 90 # Change for max limit
$sweepservodelay = 500 # Change for delay between sweep servo movements and readings

# Testing Options
$testmode = 0 # Change to 1 if testing without PING sensor

# Do not adjust these values
# $sweepcenter = $sweepmin+$sweepmax
# $sweepcenter = $sweepcenter/2
$sweepcenter = Round((($sweepmin+$sweepmax)/2),0)
$sweepprevious = $sweepmax # Do not change
$sweepcurrent = $sweepcenter # Do not change
$SweepErrorFlag = 0 # Do not change
$BoxedInErrorFlag = 0 # Do not change
$BoxedInRun = 0 # Do not change
$SweepCenterRun = 0 # Do not change
$EscapeRun = 0 # Do not change
$ScriptErrorFlag = 0 # Do not change
$isboxedin = 0 # Do not change
$penultimatemove = "none"
$lastmove = "none"

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.

Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


That's a very old version of that script. I've since uploaded an alpha of my latest version (it's alpha as I haven't physically tested it but know others have tried it).

It's written better, more modular, so that it can be adjusted to suit your requirements.

Download it here. More info on it is here (including my marked up copies of the original scripts I wrote). It should be enough to point you in the general direction.


Thank you Smile


If you get stuck with any part of it give me a shout (but try to figure it out yourself, it's more rewarding that way).

Used in conjunction with my sabertooth ramping script it should work pretty well. Click my name to check my cloud projects, it's in there somewhere (amongst a few other examples)