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
- 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])
- pwm1aP = Path('/dev/bone/pwm/1/a/period')
- pwm1aD_C = Path('/dev/bone/pwm/1/a/duty_cycle')
- pwm1aE = Path('/dev/bone/pwm/1/a/enable')
- pwm1bP = Path('/dev/bone/pwm/1/b/period')
- pwm1bD_C = Path('/dev/bone/pwm/1/b/duty_cycle')
- pwm1bE = Path('/dev/bone/pwm/1/b/enable')
- period = 10000
- duty_cycle = 5000
- try:
- while True:
- port = int(input("Please type 0 or 1 : "))
- if port == 0:
- lines.set_values([1])
- pwm1bP = 10000
- pwm1bD_C = 8000
- pwm1bE = 1
- sleep(0.5)
- elif port == 1:
- lines.set_values([1])
- pwm1aP = 10000
- pwm1aD_C = 5000
- pwm1aE = 1
- sleep(3)
- except KeyboardInterrupt:
- pwm1bE = 0
- pwm1aE = 0
- print("Kosher Salt!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement