Teacher Notes: Programming an automated vacuum cleaner Pro Preview

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1623
  • 02 Jul 2020

Example solution to the task "Program the robot to move until the touch sensor is pressed.":

# Create your objects here.
ev3 = EV3Brick() 

touch = TouchSensor(Port.S1)

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

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

left_motor.run(500) 
right_motor.run(500)

while not touch.pressed():
    pass

left_motor.brake()
right_motor.brake()

Alternative solution:

# Create your objects here. 
ev3 = EV3Brick() 

touch = TouchSensor(Port.S1) 

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

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

while not touch.pressed():
    left_motor.run(500)
    right_motor.run(500)

left_motor.brake()
right_motor.brake()

Example solution to the task "Program the robot, after the sensor has been pressed, to turn in place instead of stopping.":

# Create your objects here. 
ev3 = EV3Brick() 

touch = TouchSensor(Port.S1) 

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

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

while not touch.pressed(): 
    left_motor.run(500) 
    right_motor.run(500) 

left_motor.run_time(350, 1000, Stop.HOLD, False) 
right_motor.run_time(-350, 1000)

Example solution to the task "Put your program in a loop and let the robot walk around the room.":

# Create your objects here. 
ev3 = EV3Brick() 

touch = TouchSensor(Port.S1) 

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

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

while True:
    while not touch.pressed(): 
        left_motor.run(500) 
        right_motor.run(500) 

    left_motor.run_time(350, 1000, Stop.HOLD, False) 
    right_motor.run_time(-350, 1000)

Example solution to the task "Program your robot to make a sound every time it collides with an obstacle.":

# Create your objects here. 
ev3 = EV3Brick() 

touch = TouchSensor(Port.S1) 

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

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

while True:
    while not touch.pressed(): 
        left_motor.run(500) 
        right_motor.run(500) 

    ev3.speaker.play_file(SoundFile.BOING)
    left_motor.run_time(350, 1000, Stop.HOLD, False) 
    right_motor.run_time(-350, 1000)

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
Image for Lesson 6 - Automated vacuum cleaner
  • 5
  • 4
  • 8
  • 3d_rotation 1