User manual

ASURO - 70
-
Of course you would like an example as a complete program:
#include “asuro.h” // Line tracing the easiest way
int main(void) {
unsigned int data[2]; // Allocate storage
Init();
FrontLED(ON); // Switch ON line trace illumination
MotorDir(FWD,FWD); // Both engines go ahead
while(1){ // Eternal loop, ASURO should follow
// a line eternally
LineData(data); // Read brightness data from Phototransistors
if (data[0]>data[1]) // left brighter than right
{MotorSpeed(200,150);} // ... speed up left motor
else
{MotorSpeed(150,200);} // ... speed up right motor
}
return 0;
}
9.2.11. void OdometrieData(unsigned int *data)
The function scans the re ected light-sensor: Both LED (D13, D14) are activated and the function
returns the AD-converter values of the phototransistors (T11, T12). As in the function LineData() a
storage area with two integer values must be provided, which will be  lled by the function. The  rst
integer value contains the AD-value delivered by the left (T11), the second integer value contains
the AD-value delivered by the right (T12) phototransistor. Maximum brightness is referenced by a
value ’0’ while absolute darkness is represented by value ’1023’
5
. Normally these extreme values
will not be found, and in practice measurement values will be found in between.
Example:
Scanning the re ected light-sensors.
unsigned int data[2]; //Allocate memory
.
.
OdometrieData(data);
data[0] containes data from the left phototransistor (T11)
data[1]containes data from the right phototransistor (T12)
Just to prevent misinterpretations: OdometrieData() does not provide the number of revolutions,
but the actual illumination at the re ected light-sensors. Discerning bright and dark levels, counting
light-dark transitions and counting the number of revolutions is left to be a programmer’s job.
5
To simplify the hardware circuit these values do not correspond to the values found in the line
tracing module.
C for ASURO