Advertisement
silver2row

I guess?

Mar 19th, 2023
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. # Use for PWM on /dev/bone/pwm/
  4.  
  5. from pathlib import Path
  6. from NewMotor_TB6600 import Pwm  # see https://pastebin.com/R70P1wAn
  7. from time import sleep
  8.  
  9. GPIO = Path('/sys/class/gpio/gpio60/direction')
  10. GPIO.write_text("out")
  11.  
  12. GPIO = Path('/sys/class/gpio/gpio60/value')
  13. GPIO.write_text("0")
  14.  
  15. pwm1b = Pwm('/dev/bone/pwm/1/b/')
  16. pwm1a = Pwm('/dev/bone/pwm/1/a/')
  17.  
  18. try:
  19.     while True:
  20.         port = int(input("Please type 0 or 1 : "))
  21.         if port == 0:
  22.             GPIO.write_text("1")
  23.             pwm1a.frequency = 2000
  24. #            pwm1a.enabled = True
  25.             pwm1a.value = 0.5
  26.             sleep(4)
  27.         elif port == 1:
  28.             GPIO.write_text("1")
  29.             pwm1b.frequency = 2000
  30. #            pwm1b.enabled = True
  31.             pwm1b.value = 0.5
  32.             sleep(4)
  33.  
  34. except KeyboardInterrupt:
  35.     pwm1b.enabled = False
  36.     pwm1a.enabled = False
  37.     print("Kosher Salt!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement