First, write two procedures "left-brightness" and "right-brightness" that return the values of the two brightness sensors. These will look very similar to the procedures "left-sensor" and "right-sensor" from the Sciborg code. (Such procedures are useful because they make the code easier to read, but also easier to maintain: If you ever need to plug the sensors into different ports, you'll only have to change one line!) Next, write a procedure "print-brightness" that prints the current values of the two sensors to the top line of the LCD display like this:
L: 56 R: 72
(assuming the sensors are currently returning the values 56 and 72).
Download your procedure to the Handy Board and test it. Your
procedure should continuously update the values, similar to the Handy
Board's "display analog values" mode. If the values change too fast,
try inserting a "wait 1" statement to slow it down.
L: 122 R: 94
min 94 max 122
L: 65 R: 23
average 44
Download your code and make sure your procedures calculate the
minimum, maximum, and average of the two sensor values correctly.
Which strategy works the best?