
PAGE 15 | 1DAY ROBOTICS #2: SENSORS ©2022 M I C H A E L E T T E R S H A N K
oneDayRobotics#2-SENSORS-DCM-v1.0
1DAY OF ROBOTICS #2: PART 5 TESTING THE LINE MODULE: VIEW IN THE SERIAL TERMINAL
The serial terminal window [debugging screen] is used to view the status of input pins on the Arduino controller. The
microcontroller on the PRIMO ROBOT is the Arduino ATMEL 328P-PU as the widely used Arduino UNO.
Once the line following module has been connected up to the PRIMO ROBOT it needs to be tested to verify that it has been
wired up correctly, and that it is in fact working correctly. To check the line following robot we use the serial terminal to
check the values are falling within the 0-1023 range of the inbuilt 10 bit analogue-to-digital-converter [ADC] on the Atmel
ATMEGA 328P-PU. In the Arduino line following module we have photo transistors in the PULL UP position. That means
they are connected from the analogue inputs up to 5v (HIGH). In the PULL DOWN position we have resistors between the
analogue inputs and 0v (LOW) or GND. Resistors can be 2k2-10 kilo Ohms but we recommend 4k7 resistors.
If everything is working correctly, we will be able to see varying values similar to those in the screenshot below in the serial
monitor window. The actual values displayed should be in the 100-500 range when the line module is exposed to ambient
light, and somewhere around 500-1000 range if we shine a bright light of our cellphone torch on the line module.
If the values displayed in the serial monitor are static, either high or low, maybe ‘stuck’ on 0 or 1023 then we need to go
back and check the soldering on the line following module is good with a multimeter, also check that you have wired the
module up correctly to the microcontroller or robot’s controller motherboard as per this diagram.
After we have determined that the sensor array on the line following module is working, the next step is to place the robot
over a black line [on a white maze] alternatively a white line [on a black maze] and move the robot slowly from side to side
to see and understand how the output to the serial terminal changes.
// Click on the magnifying glass icon in the top right corner of the Arduino IDE to open serial monitor screen
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValueA0 = analogRead(A0);
int sensorValueA1 = analogRead(A1);
int sensorValueA2 = analogRead(A2);
Serial.println(sensorValueA0);
Serial.println(sensorValueA1);
Serial.println(sensorValueA2);
delay(10);
}