Week 4 - Section 3 - Follow the torch
1. Chapter 13.1 - Torch following with EdPy
Ed.EdisonVersion = Ed.V2
Ed.DistanceUnits = Ed.CM
Ed.Tempo = Ed.TEMPO_MEDIUM 10
#--------Your code below-----
if Ed.ReadRightLightLevel() - Ed.ReadLeftLightLevel() < 0:
You can find the program in the left pane of Edpy with the name Follow_torch
Shine a torch/flashlight at Edison and the robot will drive towards the light.
The presence of the torch on either the left or right of the robot will cause the robot to read higher light levels on that side of the robot. The logic of this program says that when the right light level minus the left right level is less than zero, the robot drives left, else the robot drives to the right.
It is often useful when there are lots of calculations and different possible values in a program to “trace” the different values that can occur and predict the associated behaviour. Fill out the following tracing table for this program.