silver2row

Trying alternatives to while True: on Python3 and M B C and MotorBridge.py

Oct 21st, 2020
1,641
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def StepperMotorATest():
  2.     motor.StepperMotorAInit()
  3.     if a == 22 or a == 1:
  4.         motor.StepperMotorAMove(-1000, 1000)
  5.         time.sleep(2)
  6.         motor.StepperMotorAMove(1000, 1000)
  7.         time.sleep(2)
  8.     elif a == 45 or a <= 0:
  9.         motor.StepperMotorAMove(-4500, 1000)
  10.         time.sleep(2)
  11.         motor.StepperMotorAMove(4500, 1000)
  12.         time.sleep(2)
  13.     else:
  14.         motor.StepperMotorAMove(500, 1000)
  15.         time.sleep(2)
  16.         motor.StepperMotorAMove(-500, 1000)
  17.         time.sleep(2)
  18.     #motor.StepperMotorAMove(-4500, 1000)
  19.     #time.sleep(4)
  20.     #motor.StepperMotorAMove(4500, 1000)
  21.     #time.sleep(4)
  22.  
  23. def StepperMotorBTest():
  24.     motor.StepperMotorBInit()
  25.     if b == 45 or b == 1:
  26.         motor.StepperMotorBMove(4500, 1000)
  27.         time.sleep(2)
  28.         motor.StepperMotorBMove(-4500, 1000)
  29.         time.sleep(2)
  30.     elif b == 22 or b <= 0:
  31.         motor.StepperMotorBMove(-1000, 1000)
  32.         time.sleep(2)
  33.         motor.StepperMotorBMove(1000, 1000)
  34.         time.sleep(2)
  35.     else:
  36.         pass
  37.     #motor.StepperMotorBMove(4500, 1000)
  38.     #time.sleep(4)
  39.     #motor.StepperMotorBMove(-4500, 1000)
  40.     #time.sleep(4)
  41.  
  42. try:
  43.  
  44.     if __name__=="__main__":
  45.         motor = MotorBridge.MotorBridgeCape()
  46.         while True:
  47.             StepperMotorATest()
  48.             StepperMotorBTest()
  49.  
  50. except KeyboardInterrupt:
  51.     print("Making Headway?")
RAW Paste Data