Advertisement
silver2row

Runner-Dunner!

Mar 19th, 2023
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 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('/1/b/')
  16. pwm1a = 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.enabled = True
  24.             pwm1a.value = 0.5
  25.             sleep(4)
  26.         elif port == 1:
  27.             GPIO.write_text("1")
  28.             pwm1b.enabled = True
  29.             pwm1b.value = 0.5
  30.             sleep(4)
  31.  
  32. except KeyboardInterrupt:
  33.     pwm1b.enabled = False
  34.     pwm1a.enabled = False
  35.     print("Kosher Salt!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement