Advertisement
LifeByDesign

RaspberryPi Breathing LED Python

Feb 20th, 2013
2,601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import wiringpi
  2. import time
  3. io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
  4. io.pinMode(1,io.PWM_OUTPUT)
  5. io.pwmWrite(1,0)
  6. value = 0
  7. increment = 4
  8. increasing = True
  9. count = 0
  10.  
  11. while count < 100000:
  12. io.pwmWrite(1,value)
  13.  
  14. if increasing:
  15. value += increment
  16. time.sleep(0.002)
  17. else:
  18. value -= increment
  19. time.sleep(0.002)
  20.  
  21. if (value >=1024):
  22. increasing = False
  23.  
  24. if (value <= 0):
  25. increasing = True
  26.  
  27. time.sleep(0.002)
  28. count = count + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement