Advertisement
cymplecy

RPi.GPIO PWM

Nov 7th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import RPi.GPIO as GPIO
  3. import time
  4. import datetime as dt
  5.  
  6. GPIO.setmode(GPIO.BOARD)
  7. GPIO.setwarnings(False)
  8.  
  9.  
  10. #PWM pin
  11. GPIO.setup(37,GPIO.OUT)
  12.  
  13.  
  14. count = 0
  15. while True:
  16.     pinRef = GPIO.PWM(37,50) # create new PWM instance
  17.     pinRef.start(10) # update PWM value    
  18.     time.sleep(0.05)
  19.     pinRef.stop()
  20.     GPIO.output(37,0)
  21.     time.sleep(0.05)
  22.     count = count + 1
  23.     print count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement