import supply_voltage #导入它，开启电量指示呼吸灯功能
import motor
import time
import tool
import buzzer

计时器 = None


左轮电机 = motor.smart_motor(1, direction=False)
左轮电机.set_soft_break(True)
右轮电机 = motor.smart_motor(2, direction=True)
右轮电机.set_soft_break(True)
左轮电机.openloop_turn(50)
右轮电机.openloop_turn(50)
time.sleep(3)
左轮电机.openloop_turn(0)
右轮电机.openloop_turn(0)

左轮电机 = motor.smart_motor(1, direction=False)
左轮电机.set_soft_break(True)
右轮电机 = motor.smart_motor(2, direction=True)
右轮电机.set_soft_break(True)
左轮电机.openloop_turn((-50))
右轮电机.openloop_turn((-50))
time.sleep(3)
左轮电机.openloop_turn(0)
右轮电机.openloop_turn(0)

左轮电机 = motor.smart_motor(1, direction=False)
左轮电机.set_soft_break(True)
右轮电机 = motor.smart_motor(2, direction=True)
右轮电机.set_soft_break(True)
左轮电机.openloop_turn(50)
右轮电机.openloop_turn(50)
time.sleep(1.2)
左轮电机.openloop_turn(0)
右轮电机.openloop_turn(0)
time.sleep(1)
左轮电机.openloop_turn(0)
右轮电机.openloop_turn(50)
time.sleep(1.2)
左轮电机.openloop_turn(0)
右轮电机.openloop_turn(0)
time.sleep(1)
左轮电机.openloop_turn(50)
右轮电机.openloop_turn(50)
time.sleep(1)
左轮电机.openloop_turn(0)
右轮电机.openloop_turn(0)

我的计时器1 = tool.Timer()
我的计时器1.reset()
左轮电机 = motor.smart_motor(1, direction=False)
左轮电机.set_soft_break(True)
右轮电机 = motor.smart_motor(2, direction=True)
右轮电机.set_soft_break(True)
while True:
    计时器 = 我的计时器1.get_elapsed_time(time_unit=tool.S)
    左轮电机.openloop_turn(50)
    右轮电机.openloop_turn(50)
    if 计时器 > 5:
        for count in range(2):
            buzzer.play_tone(440, 50)
            time.sleep(0.1)
            buzzer.stop()
            time.sleep(0.1)
        我的计时器1.reset()
    else:
        buzzer.stop()
