За преподавателя: Управление за Железпопътна количка с Python Pro Preview

Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео

Абонирай се

  • #1622
  • 25 Jun 2020

Примерно решение на задaчите в секция "Задвижване":

# Create your objects here. 
ev3 = EV3Brick() 

left_touch = TouchSensor(Port.S1) 
right_touch = TouchSensor(Port.S2) 

left_motor = Motor(Port.B) 
right_motor = Motor(Port.C)

# Write your program here. 
ev3.speaker.beep() 

while not left_touch.pressed(): 
    pass 
while left_touch.pressed(): 
    pass 

while not right_touch.pressed(): 
    pass  
while right_touch.pressed(): 
    pass  

left_motor.run(100) 
right_motor.run(100)
wait(2000)

Примерно решение на задaчите в секция "Ускорение":

# Create your objects here.
ev3 = EV3Brick() 

left_touch = TouchSensor(Port.S1)
right_touch = TouchSensor(Port.S2) 

left_motor = Motor(Port.B)
right_motor = Motor(Port.C)

speed = 100

# Write your program here.
ev3.speaker.beep() 

while True:
    while not left_touch.pressed():
        pass
    while left_touch.pressed():
        pass

    while not right_touch.pressed():
        pass 
    while right_touch.pressed():
        pass 

    speed = speed + 50

    left_motor.run(speed)
    right_motor.run(speed)

Примерно решение на задaчите в секция "Забавяне":

# Create your objects here. 
ev3 = EV3Brick() 

left_touch = TouchSensor(Port.S1) 
right_touch = TouchSensor(Port.S2) 

left_motor = Motor(Port.B) 
right_motor = Motor(Port.C) 

speed = 100 

# Write your program here. 
ev3.speaker.beep() 

while True: 
    while not left_touch.pressed():
        wait(200)
        speed = speed - 5
        left_motor.run(speed)
        right_motor.run(speed)
    while left_touch.pressed():
        wait(200)
        speed = speed - 5
        left_motor.run(speed)
        right_motor.run(speed)

    while not right_touch.pressed():
        wait(200)
        speed = speed - 5
        left_motor.run(speed)
        right_motor.run(speed)
    while right_touch.pressed():
        wait(200)
        speed = speed - 5
        left_motor.run(speed)
        right_motor.run(speed)

    speed = speed + 50

Курсове и занятия включващи този Урок

Този Урок е използван в следните курсове и занятия.

Image for Python за EV3 LEGO Mindstorms - ниво 2
  • 39
  • 19:58
  • 93
Image for Занятие 5 - Железопътна количка
  • 4
  • 7
  • 3
  • 3d_rotation 1