If Else

What happened when you ran the program? Did the right LED go on when there was no obstacle and go off an beep when there was an obstacle? What could you add to your code to make sure Edison’s right LED is off and Edison beeps when an obstacle is detected?

Ed.ObstacleDetectionBeam(Ed.ON)

while True:

      if Ed.ReadObstacleDetection() != Ed.OBSTACLE_NONE:

Ed.RightLed(Ed.OFF)

         Ed.PlayBeep()

         Ed.TimeWait(100, Ed. TIME_MILLISECONDS)

         Ed.ReadObstacleDetection()

     else:

         Ed.RightLed(Ed.ON)