while True: print('dm1: ', DS1.dm_1()) print('dm2: ', DS2.dm_2()) time.sleep(0.01) MD.all_motor_pwm_forward(50) dalnomer1 = DS1.dm_1() dalnomer2 = DS2.dm_2() if dalnomer1 < 25: if dalnomer2 > 25: time.sleep(3) MD.stop() MD.motor_pwm_forw_1(50) MD.motor_pwm_reverse_2(0) if dalnomer2 < 25: time.sleep(3) MD.stop() MD.motor_pwm_forw_2(50) MD.motor_pwm_reverse_1(0) else: if dalnomer2 > 25: time.sleep(3) MD.stop() MD.motor_pwm_forw_1(50) MD.motor_pwm_reverse_2(0)
import motor_driver_new as MD #Импортируем код с моторов from time import sleep #Импортируем sleep import serial1 as S #импорт кода дальномеров while 1 MD.all_motor_pwm_forward(30) time.sleep(0.25) dalnomer1 = S.dm_1() dalnomer2 = S.dm_2() print('dalnomer1', dalnomer1) print('dalnomer2', dalnomer2) if dalnomer1 < 10: MD.stop(1) if dalnomer2 > 20: MD.motor_pwm_forw_2(50) MD.motor_pwm_reverse_1(50) time.sleep(0.33) stop() dalnomer1 = S.dm_1() dalnomer2 = S.dm_2() print('dalnomer1', dalnomer1) print('dalnomer2', dalnomer2) if dalnomer1 > 20: MD.all_motor_pwm_forward(30) dalnomer1 = S.dm_1() if dalnomer1 < 5 MD.stop(1) else: