Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from PWM import Pwm
- from time import sleep
- # Use for PWM on /dev/bone/pwm/
- # see https://pastebin.com/R70P1wAn
- led = Pwm('/dev/bone/pwm/1/b', frequency=500, value=0)
- def led_fade( to_value, seconds, steps=None ):
- if steps is None:
- steps = round( seconds * 20 ) # default to 20 steps per second
- from_value = led.value
- for i in range( 0, steps ):
- sleep( seconds / steps )
- led.value = from_value + (1+i) * (to_value-from_value) / steps
- try:
- while True:
- led_fade( 1.0, 2 )
- led_fade( 0.0, 2 )
- except KeyboardInterrupt:
- led.disable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement