pwmOutput.py 543 B

123456789101112131415161718192021222324252627
  1. #import RPi.GPIO as GPIO
  2. import time
  3. import sys
  4. class PWM:
  5. def __init__(self, pin):
  6. self.pin = pin
  7. #GPIO.setup(self.pin, GPIO.OUT)
  8. #GPIO.output(self.pin, 0)
  9. #self.pwm = GPIO.PWM(self.pin, 100)
  10. #self.pwm.start(0)
  11. def setDutyCycle(self, val):
  12. #self.pwm.ChangeDutyCycle(val)
  13. pass
  14. if __name__ == '__main__':
  15. try:
  16. #GPIO.setmode(GPIO.BOARD)
  17. p = PWM(32)
  18. while True:
  19. p.setDutyCycle(int(time.time()*100 % 100))
  20. time.sleep(.03)
  21. except KeyboardInterrupt:
  22. #GPIO.cleanup()
  23. sys.exit(0)