Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- # Use for PWM on /dev/bone/pwm/
- from pathlib import Path
- from NewMotor_TB6600 import Pwm # see https://pastebin.com/R70P1wAn
- from time import sleep
- GPIO = Path('/sys/class/gpio/gpio60/direction')
- GPIO.write_text("out")
- GPIO = Path('/sys/class/gpio/gpio60/value')
- GPIO.write_text("0")
- pwm1b = Pwm('/dev/bone/pwm/1/b/')
- pwm1a = Pwm('/dev/bone/pwm/1/a/')
- try:
- while True:
- port = int(input("Please type 0 or 1 : "))
- if port == 0:
- GPIO.write_text("1")
- pwm1a.frequency = 2000
- # pwm1a.enabled = True
- pwm1a.value = 0.5
- sleep(4)
- elif port == 1:
- GPIO.write_text("1")
- pwm1b.frequency = 2000
- # pwm1b.enabled = True
- pwm1b.value = 0.5
- sleep(4)
- except KeyboardInterrupt:
- pwm1b.enabled = False
- pwm1a.enabled = False
- print("Kosher Salt!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement