Advertisement
silver2row

Some source for the MBC and g-stops?

Dec 19th, 2020
1,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. from time import sleep
  2. import Adafruit_BBIO.GPIO as GPIO
  3. import MotorBridge
  4. #import numpy as np
  5.  
  6. LED  = "P8_28"
  7. Stop = "P8_29"
  8.  
  9. GPIO.setup(LED, GPIO.OUT)
  10. GPIO.setup(Stop, GPIO.IN)
  11. motor     = MotorBridge.MotorBridgeCape()
  12. MotorB    = motor.StepperMotorBInit()
  13.  
  14. #N = 0.00025
  15. #h = np.array(N) # heights of family members (in meter)
  16. #h[0] = 1.60; h[1] = 1.85; h[2] = 1.75; h[3] = 1.80; h[4] = 0.50
  17.  
  18. #sum = 0
  19.  
  20. #for i in [0, 1, 2, 3, 4]:
  21. #    sum = sum + h[i]
  22. #    average = sum/N
  23. #    print('Average height: {:g} meter'.format(average))
  24.  
  25. try:
  26.     while True:
  27.         MotorB
  28.         motor.StepperMotorBMove(-4500, 1000)
  29.         sleep(5)
  30.         motor.StepperMotorBMove(4500, 1000)
  31.         sleep(5)
  32.         if GPIO.wait_for_edge(Stop, GPIO.RISING):
  33.             sleep(0.5)
  34.             GPIO.output(LED, GPIO.LOW)
  35.             sleep(2)
  36.             GPIO.output(LED, GPIO.HIGH)
  37.             sleep(4)
  38.             GPIO.output(LED, GPIO.LOW)
  39.             sleep(5)
  40.             MotorB
  41.             motor.StepperMotorBMove(0, 1000)
  42.             sleep(10)
  43.             motor.StepperMotorBMove(0, 1000)
  44.             sleep(10)
  45.         else:
  46.             MotorB
  47.             motor.StepperMotorBMove(2500, 1000)
  48.             sleep(5)
  49.             motor.StepperMotorBMove(-2500, 1000)
  50.             sleep(5)
  51.  
  52. except KeyboardInterrupt:
  53.     print('Hey!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement