How not to wait for distance or button. Teacher notes Pro Preview

Do not create empty loops with pass keyword.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #846
  • 20 Apr 2018

Often in your programs you will wait for sensor to continue your program.

Do NOT do this:

# wait obstacle
move.forward()
while sensor.distance > 0.50:
    pass
#eof wait < 50cm
move.stop()

 

Rather give the CPU time to multi-task.

# wait obstacle
move.forward()
while sensor.distance > 0.50:
    sleep(0.1)              # required for smooth work, let the CPU multi-task
#eof wait < 50cm
move.stop()

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Perfect STEM course. Module 1 - Smart Car with Raspberry PI
  • 118
  • 42:47
  • 136