I have written the following script to set positions for a single servo.
import RPi.GPIO as GPIO import time #set up pin 11 as an output GPIO.setmode (GPIO.BOARD) GPIO.setup (11, GPIO.OUT) frequencyHertz = 50 pwm = GPIO.PWM (11, frequencyHertz) RPosition = 0.5 R1Position = 1.0 MPosition = 1.5 L1Position = 2.0 LPosition = 2.5 positionList = [LPosition] msPerCycle = 1000/frequencyHertz for position in positionList: dutyCyclePercentage = position * 100 / msPerCycle pwm.start(dutyCyclePercentage) time.sleep (0.5) pwm.stop () GPIO.cleanup ()
I want to create a way in which I can do one of two things:
1) create a masterscript which runs 6 scripts (I have 6 servos) to set them to a specific position.
2) Use a keyboard input to set a static position of the set of servos. i.e: input 'a' will result in the 6 servos moving to a position of yaw left.
How can i do this? Ideally option 2 would be better, but option 1 is the base for this. Will i need this: http://www.ebay.co.uk/itm/Adafruit-16-Channel-12-Bit-Pwm-Servo-Driver-I2C-ControlLED-Raspberry-Pi-Arduino/191472547370?_trksid=p2054897.c100204.m3164&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20140407115239%26meid%3D5fe9f0b606ea4774ac50b3d3d270ede4%26pid%3D100204%26rk%3D1%26rkt%3D26%26sd%3D191446913846