Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import time
- with open("/sys/bus/i2c/drivers/pca9685-pwm/2-0070/pwm/pwmchip9/pwm-9:0/enable", "w+") as a:
- a.read()
- a.write == "0"
- time.sleep(2)
- a.write == "1"
- with open("/sys/bus/i2c/drivers/pca9685-pwm/2-0070/pwm/pwmchip9/pwm-9:0/period", "w+") as b:
- b.read()
- b.write = "10000000"
- # b.close()
- with open("/sys/bus/i2c/drivers/pca9685-pwm/2-0070/pwm/pwmchip9/pwm-9:0/duty_cycle", "w+") as c:
- c.read()
- c.write = "1000000"
- # c.close()
- for i in range(0, 180, 5):
- angle = int(input("0 to 180: "))
- if angle < 45:
- time.sleep(2)
- a = "1"
- c = "1500000"
- elif angle >= 45:
- time.sleep(2)
- a = "1"
- c = "2000000"
- elif angle <= 180:
- time.sleep(2)
- a = "1"
- b = "10000000"
- c = "2000000"
- elif angle == 135:
- time.sleep(2)
- a = "1"
- c = "1500000"
- else:
- angle == 90
- time.sleep(2)
- a = "1"
- c = "2000000"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement