Exemple #1
0
 def __init__(self, fr = MOTOR(6, 5, 4), br = MOTOR(7, 8, 9), bl = MOTOR(12, 11, 10), fl = MOTOR(13, 14, 15)):
     print('Initialize device controller')
     self._servo_controller = PCA9685ROBOT()
     self._forward_right_motor = fr
     self._forward_left_motor = fl
     self._backward_right_motor = br
     self._backward_left_motor = bl
     self._periodic_timer_milliseconds = 100
# Initialise the PCA9685 using the default address (0x40).
pwm = PCA9685ROBOT()

# Alternatively specify a different address and/or bus:
#pwm = Adafruit_PCA9685.PCA9685(address=0x41, busnum=2)

# Configure min and max servo pulse lengths
servo_min = 150  # Min pulse length out of 4096
servo_med = 600  # Max pulse length out of 4096
servo_max = 2000

# Set frequency to 60hz, good for servos.
pwm.set_pwm_freq(60)

fwd_rht = MOTOR(6, 5, 4)
bwd_rht = MOTOR(7, 8, 9)
bwd_lft = MOTOR(12, 11, 10)
fwd_lft = MOTOR(13, 14, 15)

rover = ROVER()

print('Moving servo on channel 0, press Ctrl-C to quit...')
try:
    while True:
        # Move Rover Forward
        rover.forward_rover()
        time.sleep(5)
        rover.stop_rover()
except KeyboardInterrupt:
    print('Attempt Program interrupt')