Advertisement
silver2row

Some File Editing for the PCA9685?

Jul 2nd, 2020
1,353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import time
  2. import os
  3.  
  4. with open("/sys/class/i2c-adapter/i2c-2/2-0070/pwm/pwmchip9/pwm-9:0/enable", "w") as a:
  5.     a.write = int(0)
  6.     time.sleep(2)
  7.     a.write = int(1)
  8.  
  9. with open("/sys/class/i2c-adapter/i2c-2/2-0070/pwm/pwmchip9/pwm-9:0/period", "w") as b:
  10.     b.write = int(10000000)
  11.  
  12. with open("/sys/class/i2c-adapter/i2c-2/2-0070/pwm/pwmchip9/pwm-9:0/duty_cycle", "w") as c:
  13.     c.write = int(1000000)
  14.  
  15. try:
  16.     angle = int(input("0 to 180: "))
  17.     if True:
  18.         if angle == 0 or angle == 45:
  19.             time.sleep(3)
  20.             a.write = int(1)
  21.             b.write = int(10000000)
  22.             c.write = int(2000000)
  23.  
  24.         elif angle == 90 or angle ==  135:
  25.             time.sleep(3)
  26.             a.write = int(1)
  27.             b.write = int(10000000)
  28.             c.write = int(1500000)
  29.  
  30.         else:
  31.             time.sleep(2)
  32.             a.write = int(1)
  33.             b.write = int(10000000)
  34.             c.write = int(1000000)
  35.     if not True:
  36.         a.write = int(0)
  37. except:
  38.     KeyboardInterrupt
  39.     print("Hello, you have exited the program.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement