import RPi.GPIO as GPIO
import time

"""
Explanation: Controlling a Servo Motor with The Raspberry Pi GPIO Port
Before proceeding double check your wiring.
End of explanation
"""


GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.OUT)

p = GPIO.PWM(18, 50)

"""
Explanation: Set up the port as a PWM port with a 50Hz frequency:
End of explanation
"""


p.start(2.5)

"""
Explanation: Start at the 0 degree position (for most motors, this is a 2.5% duty cycle).
End of explanation
"""


p.ChangeDutyCycle(5.0)

p.ChangeDutyCycle(7.0)

p.ChangeDutyCycle(4.0)
time.sleep(0.2)
p.ChangeDutyCycle(10.0)
time.sleep(0.2)
p.ChangeDutyCycle(5.0)
time.sleep(0.2)
p.ChangeDutyCycle(7.0)
time.sleep(0.2)

p.stop()
GPIO.cleanup()

"""
Explanation: Move that motor around.
End of explanation
"""


