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]
- CHIP1 = 'gpiochip1'
- LINE_OFFSET1 = [18]
- chip = gpiod.Chip(CHIP)
- chip1 = gpiod.Chip(CHIP1)
- lines = chip.get_lines(LINE_OFFSET)
- lines.request(consumer=' ', type=gpiod.LINE_REQ_DIR_OUT)
- lines1 = chip.get_lines(LINE_OFFSET1)
- lines1.request(consumer=' ', type=gpiod.LINE_REQ_DIR_IN)
- lines.set_values([0])
- #lines1.set_values([0])
- try:
- port = int(input("Please type 0 or 1 : "))
- if port == 0:
- lines.set_values([0])
- pwm1b = Pwm('/dev/bone/pwm/1/b/', frequency=2000)
- pwm1b.value = 0.5
- sleep(1)
- lines.set_values([1])
- sleep(5)
- elif port == 1:
- lines1.set_values([0])
- pwm1b = Pwm('/dev/bone/pwm/1/b/', frequency=0)
- pwm1b.value = 0.0
- sleep(1)
- lines1.set_values([1])
- sleep(1)
- except KeyboardInterrupt:
- lines.set_values([0])
- lines1.set_values([0])
- pwm1b = Pwm('/dev/bone/pwm/1/b', frequency=0)
- pwm1b.value = 0.0
- print("Kosher Salt!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement