Login - Register -

Building a Robot

IR Line followers

Assembly

  1. Locate T-shaped sensor mounting plate
  2. use heat gun to bend t-plate aprox 2/3rds way towards narrow end, so that when the sensors are screwed on they will ride a few mm above the floor
  3. bolt sensors to wide end using nuts + 4x M3 8mm CS screws
  4. bolt sensor plate to chassis using 2x M3 10mm pan head screws + nuts
  5. Attach IR control board to Controller plate with 2x M3 4mm pan head screws
  6. 6 longer dupont wires from IR board to motor control:
    1. 4 data wires to 'analog in'
    2. power to 5v, ground to ground
  7. 12 shorter dupont wires from IR board to IR sensors

Theory

Each sensor is a matched pair of infra-red (IR) LED light source and a receiver, they bounce light off of the surface and measure how much gets reflected. white / light surfaces reflect a lot of the light, darker / black surfaces absorb much of it.

Wiring

The controller board for the sensors has one pot (potentiometer, or variable resistor) for each sensor, this adjusts the trigger threshold that flips the output from light to dark.

The four outputs are connected to the Arduino analog input pins as they are not use by the motor control board, they can be configured as digital inputs with the normal pinMode(n, INPUT) and digitalRead() commands.

Use a piece of paper/card with piece of black insulation tape on it to calibrate the sensors, adjust the pots until the corresponding LEDs on the control board reliably turn on and off as you pass the black stripe beneath the sensors.

Usage

By monitoring which lines are high or low we can 'see' if the line we are following is central or to one side and adjust the relative speeds of the motors to correct and centre it again. or if it is lost, slowly rotate the robot until we locate it again.

Example Test Program

 #define LANE_A  14
 #define LANE_B  15
 #define LANE_C  16
 #define LANE_D  17

 void setup()
 {
   Serial.begin(9600);

   pinMode(LANE_A, INPUT);
   pinMode(LANE_B, INPUT);
   pinMode(LANE_C, INPUT);
   pinMode(LANE_D, INPUT);
 }

 void loop()
 {
   Serial.print("IR Lane: ");
   if (digitalRead(LANE_A) == HIGH) Serial.print("HIGH "); else Serial.print("LOW  ");
   if (digitalRead(LANE_B) == HIGH) Serial.print("HIGH "); else Serial.print("LOW  ");
   if (digitalRead(LANE_C) == HIGH) Serial.print("HIGH "); else Serial.print("LOW  ");
   if (digitalRead(LANE_D) == HIGH) Serial.print("HIGH "); else Serial.print("LOW  ");
   Serial.println();
 }
- Last change March 23, 2016, at 07:52 PM
- Registered in England and Wales 08777436