Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- import Adafruit_BBIO.GPIO as GPIO
- import MotorBridge
- #import numpy as np
- LED = "P8_28"
- Stop = "P8_29"
- GPIO.setup(LED, GPIO.OUT)
- GPIO.setup(Stop, GPIO.IN)
- motor = MotorBridge.MotorBridgeCape()
- MotorB = motor.StepperMotorBInit()
- #N = 0.00025
- #h = np.array(N) # heights of family members (in meter)
- #h[0] = 1.60; h[1] = 1.85; h[2] = 1.75; h[3] = 1.80; h[4] = 0.50
- #sum = 0
- #for i in [0, 1, 2, 3, 4]:
- # sum = sum + h[i]
- # average = sum/N
- # print('Average height: {:g} meter'.format(average))
- try:
- while True:
- MotorB
- motor.StepperMotorBMove(-4500, 1000)
- sleep(5)
- motor.StepperMotorBMove(4500, 1000)
- sleep(5)
- if GPIO.wait_for_edge(Stop, GPIO.RISING):
- sleep(0.5)
- GPIO.output(LED, GPIO.LOW)
- sleep(2)
- GPIO.output(LED, GPIO.HIGH)
- sleep(4)
- GPIO.output(LED, GPIO.LOW)
- sleep(5)
- MotorB
- motor.StepperMotorBMove(0, 1000)
- sleep(10)
- motor.StepperMotorBMove(0, 1000)
- sleep(10)
- else:
- MotorB
- motor.StepperMotorBMove(2500, 1000)
- sleep(5)
- motor.StepperMotorBMove(-2500, 1000)
- sleep(5)
- except KeyboardInterrupt:
- print('Hey!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement