pwmOutput.py 622 B

1234567891011121314151617181920212223242526272829303132
  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. def stop(self):
  15. #self.pwm.stop()
  16. #GPIO.output(self.pin, 0)
  17. pass
  18. if __name__ == '__main__':
  19. try:
  20. #GPIO.setmode(GPIO.BOARD)
  21. p = PWM(32)
  22. while True:
  23. p.setDutyCycle(int(time.time()*100 % 100))
  24. time.sleep(.03)
  25. except KeyboardInterrupt:
  26. #GPIO.cleanup()
  27. sys.exit(0)