I have a question about this code. The program takes analog input from the ir sensors and controls the motors accordingly. In the sensor_check routine there is this:
for temp = 0 to 9
adin 17, filter(temp)
next
Here filter is an array of 10 words.
Why is it necessary to read pin17 10 times?
The manual says that the resoulution is 10 bits, which probably has somthing to do with this, but I’m not quite sure what.
No it it is not necessary to read it in 10 times. However analog voltages are not always 100% consistent, so the next part of the code, takes an average of the readings, to smooth out the differences.
for temp = 0 to 9
adin 17, filter(temp)
next
ir_right = 0
for temp = 0 to 9
ir_right = ir_right + filter(temp)
next
ir_right = ir_right / 90
Not sure about the / by 90 but…
There is another line in the program that I can’t read. I looked though the BasicAtom PRO Manual but can’t find an explanation for what the “:” (colon) operator does.