Hardware Reference
In-Depth Information
NOTE The Arduino Robot's compass takes readings relative to magnetic north, and
the compass can be aff ected by magnetic fi elds. Make sure to keep your robot away
from speakers, motors, or other strong magnets that could temporarily make the com-
pass give false readings.
The motor board also contains i ve infrared sensors used for line following.
The motor board can access the reading for the individual sensors, but with the
control board, sketches must use updateIR() :
This function takes no parameters and does not return any data. What it does
is update an array, readable through Robot.Irarray[] :
for(int i=0; i<=4; i++)
Serial.print(Robot.IRarray[i]); // Print the value of each IR sensor
Serial.print(" ");
The control board also has a knob, a potentiometer. Powered by 5 V, it is
connected to an analog-to-digital converter with 10-bit precision. It maps input
voltages to an integer value between 0 and 1023, and is accessible through
knobRead() :
result = Robot.knobRead();
This function returns an int , the value read from the ADC.
The control board also has a i ve-button keyboard. These keys can be read
through keyboardRead() :
result = Robot.keyboardRead();
This function returns a constant reporting the button that is being pressed.
See the possible values in Table 22-1.
Table 22-1: Keyboard Return Codes
Left button pressed
Right button pressed
Up button pressed
Down button pressed
Middle button pressed
No button pressed
Search WWH ::

Custom Search