Add servo example, servo action is jerky but functional
This commit is contained in:
parent
fe1c4cf389
commit
8dcbaded2d
|
@ -0,0 +1,19 @@
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
import time
|
||||||
|
|
||||||
|
servoPIN = 17
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
GPIO.setup(servoPIN, GPIO.OUT)
|
||||||
|
|
||||||
|
p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz
|
||||||
|
p.start(2.5) # Initialization
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
p.ChangeDutyCycle(10)
|
||||||
|
time.sleep(2)
|
||||||
|
p.ChangeDutyCycle(2.5)
|
||||||
|
time.sleep(2)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
p.stop()
|
||||||
|
GPIO.cleanup()
|
||||||
|
|
Loading…
Reference in New Issue