Advertisement
GammaTroniques

Code Distributeur de Croquette servo.py

Mar 2nd, 2019
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. GPIO.setmode(GPIO.BCM)
  4. GPIO.setup(17, GPIO.OUT)
  5. GPIO.setwarnings(False)
  6.  
  7. ajoutAngle = 5
  8. print("ok")
  9. pwm=GPIO.PWM(17,100)
  10. pwm.start(5)
  11.  
  12. i = 0
  13. while i < 5:
  14.     angle1 = 80
  15.     duty1 = float(angle1)/10 + ajoutAngle
  16.  
  17.     angle2=180
  18.     duty2= float(angle2)/10 + ajoutAngle
  19.  
  20.     pwm.ChangeDutyCycle(duty1)
  21.     time.sleep(1)
  22.     pwm.ChangeDutyCycle(duty2)
  23.     time.sleep(1)
  24.     i= i + 1
  25. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement