Thanks,
Keith
Code: Select all
# Create motors
PWM_A2 = board.A2
PWM_A3 = board.A3
PWM_FREQ = 25
DECAY_MODE = motor.SLOW_DECAY
positive_pwm1 = pwmio.PWMOut(PWM_A2, frequency=PWM_FREQ)
negative_pwm1 = pwmio.PWMOut(PWM_A3, frequency=PWM_FREQ)
motor_right = motor.DCMotor(positive_pwm1, negative_pwm1)
motor_right.decay_mode = DECAY_MODE
def move_fwd(duration):
""" Move forward for duration amount of time. """
print()
motor_right.throttle = .5
print("Forward for %s seconds" % duration)
pixel_control([0, 9], GREEN, 'on')
time.sleep(duration)
print()
pixel_control([0, 9], GREEN, 'off')
motor_right.throttle = 0
while True:
move_fwd(.5)
time.sleep(10)