United Kingdom
Asked — Edited
Resolved Resolved by DJ Sures!

Getpwm Returning 0

I want to return the value from D1 and D0 whilst tracking an object, i'm using the GetPWM command but only ever get a "0" returned. Am i missing something?

ControlCommand("Camera", CameraColorTrackingEnable)


$head0=GetPWM( D0 ) 
$head1=GetPWM( D1 ) 




Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.


you are using the wrong function, replace GetPWM with GetDigital.


GetPWM (digitalPort) Gets the PWM (Pulse Width Modulation) of specified port PWM is between 0 and 100


GetDigital( Port ) Returns the Digital value of the specified port as a 0 or 1

GetPWM returns the last value used with a PWM function.


PWM(D0, 75)
PWM(D1, 100)
Print(GetPWM(D0)) => 75
Print(GetPWM(D1)) => 100


I believe you are attempting to determine the position of a servo? If that is the case, use GetServo(). As stated by @ptp, the GetPWM is reserved for PWM specific functions, which is identified by its naming convention PWM vs SERVO.

Find out how a servo works from the learn section here: https://synthiam.com/Tutorials/Lesson/48?courseId=6

Additionally, there are dozens of variables for the camera control - which you can view by looking at the Variable Tab while editing. More information on editing EZ-Script can be found in the learn section here: https://synthiam.com/Tutorials/Course/6

Camera variables can help to determine the physical location of the object on the screen.

However, if you are looking to read a servo position, use GetServo(). The JD project which you are building from has some script examples that demonstrate, such as PointAndTrack

United Kingdom

Thanks DJ.

getservo() works a treat