Question about the AWD1AUTO.BAS code

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.

Thanks
Hal

Hi Hal,

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…

Kurt

Ah, I see. Thanks Kurt.

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.

NormalizeValue = lhori : NormalizeNull = lhori_null : Gosub Normalize : lhori = NormalizeValue

Is this a line separator? (ie, allows me to put several statements on the same line)

Yep, I think the : allows you to put multiple commands on the same physical line.

Likewise the | allows you to continue a statement on multiple lines. I use this for example if I am doing a complex serout.

Kurt