Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pysabertooth import Sabertooth
- from time import sleep
- import Adafruit_BBIO.GPIO as GPIO
- import MotorBridge
- saber = Sabertooth('/dev/ttyS2', baudrate=9600, address=128, timeout=0.1)
- LED = "P8_28"
- Stop = "P8_29"
- GPIO.setup(LED, GPIO.OUT)
- GPIO.setup(Stop, GPIO.IN)
- motor = MotorBridge.MotorBridgeCape()
- MotorB = motor.StepperMotorBInit()
- try:
- while True:
- if GPIO.input(LED):
- GPIO.wait_for_edge(Stop, GPIO.RISING)
- sleep(0.5)
- saber.drive(1, 25)
- sleep(5)
- saber.drive(1, -25)
- sleep(5)
- GPIO.output(LED, GPIO.LOW)
- sleep(2)
- GPIO.output(LED, GPIO.HIGH)
- sleep(4)
- #saber.stop()
- elif GPIO.wait_for_edge(Stop, GPIO.FALLING):
- sleep(0.5)
- saber.drive(1, 50)
- sleep(5)
- saber.drive(1, -50)
- sleep(5)
- elif GPIO.wait_for_edge(Stop, GPIO.RISING):
- sleep(0.5)
- MotorB
- motor.StepperMotorBMove(0, 1000)
- else:
- MotorB
- motor.StepperMotorBMove(2000, 1000)
- sleep(2)
- motor.StepperMotorBMove(-2000, 1000)
- sleep(4)
- except KeyboardInterrupt:
- print("Hey!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement