
Understanding the code (cont.)
The [
IOpins.h
] tab is your programs wiring diagram. If you want to change which pins are used for a servo or sensor
then that change must be reflected here. If you need to replace a servo or even if you are wiring up the robot for the
first time then this tab is your guide as to what device connects to which pin.
The [
IReye
] tab is where the data from the eye is generated. This code first takes a reading of all sensors
with the IR LEDs turned ON. This reading is a combination of the ambient IR light plus the IR light from the
LEDs being reflected from any nearby objects.
Then the LEDs are turned OFF and the sensors are read again. This reading is only the ambient IR light.
These values are subtracted from the previous sensor readings to give a value equal to just the IR light
from the IR LEDs being reflected by any nearby objects.
This value depends a lot on the size and colour of the object being tracked. If there is a lot of ambient IR
light such as bright sunlight then the sensor can be blinded. The eye works best indoors or at night.
17