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
- import gpiod
- import os
- CHIP = 'gpiochip1'
- LINE_OFFSET = [28]
- chip = gpiod.Chip(CHIP)
- lines = chip.get_lines(LINE_OFFSET)
- lines.request(consumer=' ', type=gpiod.LINE_REQ_DIR_OUT)
- lines.set_values([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:
- lines.set_values([1])
- pwm1b.duty_cycle = 1000
- pwm1b.frequency = 2000
- pwm1b.value = 0.5
- pwm1b.enabled = True
- sleep(2)
- elif port == 1:
- lines.set_values([1])
- pwm1a.duty_cycle = 1000
- pwm1a.frequency = 2000
- pwm1a.value = 0.5
- pwm1a.enabled = True
- sleep(2)
- except KeyboardInterrupt:
- pwm1b.enabled = False
- pwm1a.enabled = False
- print("Kosher Salt!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement