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.

Get Started
Asked — Edited
Resolved Resolved by Rich!

Slide Script Help

So Im trying to use use a slide script. I have the variable setup as $RightPWM. If I want to make another script that uses that variable to set the pwm how would I do that? Aka $RightPWM= 5, I want the pwm to change to 5. How would I do this? If statement? Not sure how I would make it.


Upgrade to ARC Pro

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

United Kingdom


PWM(digital port, speed)

Assuming the port is D0 the command would be;


PWM(D0, $RightPWM)

You will need to make sure $RightPWM is set to something before running the script or command which uses the variable though otherwise it will error as the variable will not exist. I usually add all variables to an init script and set them to 0, this ensures the variables exist and will avoid any scripts failing due to the possibility of an error.
thanks rich. is there a way to make it so its always one more than the variable?
United Kingdom
I don't see the point in that, that's the whole idea of a variable but yes.


Ok thanks. My method is that is if the pwm needs to be 0, and the minimum value for the variable is 1, I guess I could run the pwm one less to successfully stop the motor. Sorry if I'm not making sense lately. Not sure what's gotten into me.
United Kingdom
Slide Script allows a minimum value of 0 and maximum of 1000 and is configurable. If you set it from 0 to 100 and use the variable for a PWM command it should be exactly the same as adding the PWM control (which therefore makes the whole idea of using the slide script for PWM redundant since you could use the control already available).

What is it you are trying to achieve? There may be a better/different method.
Its possible im going to run other scripts based of the variable so I just thought id get it sorted out.
United Kingdom
You could always use the GetPWM() command to run other scripts based on the PWM of the port...


IF(GetPWM(D0) > 50)

or a WaitForChange() and a GetPWM()



Either way will work, using a slide script or using a PWM control, I always prefer to use the native controls over scripting when possible, they are there to make things easier.