I have my cameras pan and tilt servos set to be controlled by 'w,a,s,d' and I have 'x' set to a "snap to" position and then return to the previous position on release of the 'x' key. I started doing some trouble shooting with the 'w' key. I've put my code below. I've described my problem beneath the code.
#'w down' #get original servo position $preTiltPos = GetServo(D0) #Printing for test purposes Print("PreTilt = $preTiltPos") #Move servo Move (D0,reverse) #get current servo position $postTiltPos = GetServo(D0) #print new servo position Print("PostTilt = $postTiltPos") #'x down' #get current servo positions $PanPos = GetServo(D2) $TiltPos = GetServo(D0) #set servos to desired positions Servo(D0,54) Servo(D2,50) #'x up' #return to previous postion Servo(D0,$TiltPos) Servo(D2,$PanPos)
The problem seems to be that when I use a keyboard command it registers the positions as either 1 or 100. The function works if I move the camera servos with any of the control panels because they are reporting their positions accurately.
Why do the servos throw these signals when I use the keyboard controls? Is it because I'm using 'Move'? I can see how that may be the problem. I want the servo to move as long as I'm pressing the key. I don't want to have to use multiple 'taps'. I like the analogue feel. How can I do this without using 'Move'? Some sort of loop with ServoUp, ServoDown?
Thanks in advanceSkip to comments