For the curious Pro Preview

Waiting for translation from Bulgarian.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1636
  • 02 Jul 2020
# Create your objects here. 
ev3 = EV3Brick() 

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

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

right_speed = 1000
left_speed = 1000

right_flag = Flase
left_flag = False

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

while True:

    if right_touch.pressed():
        right_motor.run(right_speed)
        right_flag = True
    else:
        right_motor.brake()
        if right_flag:
            right_speed = right_speed * (-1)
            right_flag = False

    if left_touch.pressed():
        left_motor.run(left_speed)
        left_flag = True
    else:
        left_motor.brake()
        if left_flag:
            left_speed = left_speed * (-1)
            left_flag = False

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Python with LEGO Mindstorms EV3 - Level 2
  • 39
  • 19:58
  • 93