run_time = 3 motor_b = LargeMotor(address='outB') motor_c = LargeMotor(address='outC') motor_b.reset() motor_c.reset() motor_b.command = 'run-direct' motor_c.command = 'run-direct' trigger = TouchSensor() print("Fire when ready!") while True: if trigger.value() == True: break else: sleep(.01) motor_b.duty_cycle_sp = power motor_c.duty_cycle_sp = power sleep(run_time) motor_b.duty_cycle_sp = 0 motor_c.duty_cycle_sp = 0 sleep(1)
print(color) toDo = robot.colorResponse(color) print(history) if toDo is not None: history = "start" if history == "stop": motorAreRunning = False if toDo["event"] is None: robot.do(toDo["toDo"]) else: robot.do(toDo["toDo"]) robot.brickDownEvent() else: if getColorFromRaw(cs) != 4: while getColorFromRaw(cs) == None: mot1.run_forever(speed_sp=400) mot2.run_forever(speed_sp=400) else: mot1.stop() mot2.stop() sleep(0.25) #wait for signal to start while True: if getColorFromRaw(cs) == 4 and ts.value() == 1: main() break
motor_c = LargeMotor(address='outC') motor_b.reset() motor_c.reset() motor_b.command = 'run-direct' motor_c.command = 'run-direct' trigger = TouchSensor() print("Fire when ready!") while True: if trigger.value() == True: break else: sleep(.01) motor_b.duty_cycle_sp = power motor_c.duty_cycle_sp = power sleep(run_time) motor_b.duty_cycle_sp = 0 motor_c.duty_cycle_sp = 0 sleep(1)