Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(25, GPIO.OUT)
- p = GPIO.PWM(25, 50)
- print("center")
- p.start(7.5)
- time.sleep(2)
- print("45 degree")
- p.ChangeDutyCycle(5)
- time.sleep(2)
- print("The other 45 degree")
- p.ChangeDutyCycle(10)
- time.sleep(2)
- print("Center again")
- p.ChangeDutyCycle(7.5)
- time.sleep(2)
- print("stop")
- p.stop()
- GPIO.cleanup()
- from gpiozero import Servo
- from time import sleep
- myGPIO=25
- myCorrection=0.45
- maxPW=(2.0+myCorrection)/1000
- minPW=(1.0-myCorrection)/1000
- servo = Servo(myGPIO,min_pulse_width=minPW,max_pulse_width=maxPW)
- while True:
- servo.value=0
- print("0")
- sleep(10)
- servo.value=0.6
- print("0")
- sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement