silver2row

BuggyCode and Initializing Classes w/ a Function!

Oct 17th, 2021
1,163
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python3
  2.  
  3. # Looking around some?
  4.  
  5. import MotorBridge
  6. from time import sleep
  7.  
  8. ab = 0.0
  9. ac = 0.0
  10. ad = 0.0
  11. ae = 0.0
  12. af = 0.0
  13. ag = 0.0
  14.  
  15. motor = MotorBridge.MotorBridgeCape()
  16. motor.StepperMotorAInit()
  17.  
  18. class board:
  19.     def StepperMotorATest():
  20.         ab = 55
  21.         ac = 45
  22.         ad = 35
  23.         ae = 25
  24.         af = 85
  25.         ag = 75
  26.  
  27.         core = int(input("Please provide a numerical value between 0 and 100\n "))
  28.         if ab >= 86:
  29.             motor.StepperMotorAMove(2500, 1000)
  30.             sleep(5)
  31.             motor.StepperMotorAMove(-2500, 1000)
  32.         elif ag == 76:
  33.             motor.StepperMotorAMove(1000, 1000)
  34.             motor.StepperMotorAMove(-1000, 1000)
  35.         elif af <= 25:
  36.             motor.StepperMotorAMove(0, 0)
  37.             sleep(5)
  38.         elif ac == 50:
  39.             motor.StepperMotorAMove(750, 1000)
  40.             sleep(5)
  41.             motor.StepperMotorAMove(-750, 1000)
  42.         elif ad <= 24 / 2:
  43.             motor.StepperMotorAMove(3600, 1500)
  44.             sleep(5)
  45.             motor.StepperMotorAMove(-3600, 1500)
  46.         else:
  47.             motor.StepperMotorAMove(500, 800)
  48.             sleep(5)
  49.             motor.StepperMotorAMove(-500, 800)
  50.  
  51.  
  52. print("Starting the Script, try to press Control-C to quit!\n")
  53.  
  54. try:
  55.     while True:
  56.         board.StepperMotorATest()
  57.         sleep(5)
  58.  
  59. except KeyboardInterrupt:
  60.     print("You may have just pressed Control-C!\n")
RAW Paste Data