Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from time import sleep
- import signal
- import sys
- from pwm_driver import Pwm
- LED = Pwm(path="/sys/class/pwm/pwmchip0/pwm0/", enabled=False, period=100000, duty_cycle=85000)
- Duty = 0
- low = 0.8 # Smallest angle (in ms)
- hi = 2.4 # Largest angle (in ms)
- pos = 1.5 # Current position, about middle ms)
- step = 0.4 # Step size to next position
- try:
- LED.enabled=True
- while True:
- pos += step # Take a step
- if(pos > hi or pos < low):
- step *= -1
- Duty = LED.duty_cycle
- Duty = str(pos)
- print('pos = ' + str(pos) + ' duty_cycle = ' + Duty)
- (LED.duty_cycle)
- sleep(0.2)
- except KeyboardInterrupt:
- LED.enabled=False
- pass
- # Trying to fade a LED
- # This is from your (@zmatt) PWM driver written a while back and some code from docs.beagleboard.org
Advertisement
Add Comment
Please, Sign In to add comment