Hi I have used the following code for a specific movement for the servos. In my project I have 3 servos per nacelle (2 nacelles) to control the motions for the bicopter. I want to control the inputs through a PS3 controller:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
frequencyHertz = 50
pwm = GPIO.PWM(11, frequencyHertz)
RightPosition=0.5
R1Position=1.0
middlePosition=1.5
L1Position=2.5
PositionList=[RightPosition, middlePosition, LeftPosition, R1Position, L1Position]
msPerCycle = 1000/frequencyHertz
for Position in positionList:
dutyCyclePercentage = position * 100 / msPerCycle
pwm.start(dutyCyclePercentage)
time.sleep(1)
pwm.stop()
GPIO.cleanup()
I want to assign a specific servo configuration to be controller by the RPi. Is there a way that someone knows how to do this? something I can reference? Ideally the a joystick layout for dynamic motion would be ideal ie: gradual movements in the joystick would allow for a gradual change in specific servos for yaw and pitch. But I am not sure how to do this. I am very new to coding. Maybe the code above needs to be adapted for this new set up? any suggestions?
I have found the following for installing and setting up the PS3 controller to the RPi: http://www.raspians.com/Knowledgebase/ps3-dualshock-controller-install-on-the-raspberry-pi/
https://teamprincipia.wordpress.com/2007/12/27/joystick-control-of-a-servo/