
Kiteman
United Kingdom
Asked
— Edited

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)
:TrackingLoop
$head0=GetPWM( D0 )
$head1=GetPWM( D1 )
print($head0)
print($head1)
sleep(1000)
Goto(TrackingLoop)
you are using the wrong function, replace GetPWM with GetDigital.
GetPWM returns the last value used with a PWM function.
ex:
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
Thanks DJ.
getservo() works a treat
Excellent to hear