Advertisement
Lonely_Wanderer

Решение задачи 3

Oct 9th, 2023
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. motor_a = Motor(Port.A)
  2. motor_b = Motor(Port.B)
  3. motor_c = Motor(Port.C)
  4. t1 = TouchSensor(Port.S1)
  5. t2 = TouchSensor(Port.S2)
  6. g = GyroSensor(Port.S3)
  7.  
  8. motor_a.reset_angle(0)
  9. motor_b.reset_angle(0)
  10.  
  11. while True:
  12.     if t1.pressed() and t2.pressed():   # нажаты обе
  13.         motor_c.run(560)
  14.     elif t1.pressed()# нажата левая
  15.         motor_a.run_target(300,90)
  16.     elif t2.pressed()# нажата правая
  17.         motor_b.run_target(300,90)
  18.     else: # ни одна не нажата
  19.         motor_b.run_target(300,0)
  20.         motor_a.run_target(300,0)
  21.         motor_c.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement