Introduction: DIY Line Follower Sensor Array

About: I break things so I can figure out how they're made when I put it back together.

In this Instructable you'll learn how to make your very own Line follower sensor array!!

It consists of two parts :

  1. The IR LED board.
  2. The Op-Amp Board.

The IR LED board consists of an array of 5 pairs of IR LEDs and photodiodes.The neat part about the board is that you can add more IR Tx/Rx pairs if you need to very easily...while making sure your supply has enough juice to power the LEDs.

Since the output of the IR sensor alone is in milivolt the Arduino will always read it as LOW no matter what....therefore an Amplifier is needed to convert the sensor output to TTL level..this is where the Op-Amp board comes in.

Finally the output of the Op-amp board is fed into the Arduino digital pin and you get a reading of HIGH for Black and LOW for White. (Since I plan on using it to follow a black line...more on that later.)

Some prerequisites that you might need are :

  1. Basic idea of how to solder.
  2. Basic idea of arduino programming.

Step 1: Parts List

For the IR LED board :

  1. IR LED and Photodiode pair X 5
  2. 10kΩ Resistor X 5
  3. 100Ω Resistor X 5
  4. Connecting Wires
  5. Male header pins
  6. Perf board or PCB

For the Op-amp board :

  1. LM358 X 3
  2. 16-pin IC sockets X 2
  3. 4.7kΩ Resistors X 10
  4. Green LEDs X 5 (optional)
  5. 100Ω Resistors X 5
  6. Female and Male Header pins
  7. PCB
  8. Connecting Wires

Additional Tools :

  1. Soldering Iron
  2. Solder Wire
  3. Hot glue gun
  4. Breadboard to test everything before soldering.
  5. Arduino IDE installed on the computer.

And ofcourse an Arduino to make sense of all your readings :p

Step 2: Making the IR LED Array

Making the IR LED board is pretty easy.Take a look a the ckt diagram in order to familiarize yourself with the connections.

For the IR LED : The longer pin is the anode and the shorter pin is the cathode.

For the photodiode/phototransistor : The longer pin is the the emitter and the shorter one the collector...another way to identify the collector is that the side of the side of the photodiode is flat.

I've marked out each terminal for both the IR LED and the phototdiode.Now on to the soldering...

Start by soldering twomale header pins for the power and ground lines.Then place the IR led and the photodiode as shown in the picture.The anode of the led and the collector of the photodiode face each other.(easier to understand from the picture.)

Then place the two resistors (10kΩ and 100Ω) in the following way...

For the 10kΩ resistor : One terminal to the emitter of the photodiode...the other terminal to ground.

For the 100Ω resistor : One terminal to the cathode of the IR led and the other terminal to ground.

Have a look at the pictures for a better understanding of the connections.

Now connect a set of 5 male header pins on top of the pcb...take a wire and connect each junction of the 10kΩ resistor and emitter to each header pin.(Have a look at the pictures.)

Follow these steps for the other four pairs leaving approximately 2cm between each pair(this distance depends on the resolution you want for your sensor and also the line's thickness.)

Now on to the Op-Amp board.....

Step 3: Making the Board for the Op-Amps

As explained before the op-amps are needed to convert the IR sensor outputs to TTL logic.

The op-amp I've used is LM358 as its cheap and easily available.The chip contains 2 op-amps so 3 chips are needed for 5 led sensors(2 per chip).

The sensor input goes to the non-inverting terminal(pins 3 and 5).

Pin 1 and 7 of the op-amp are the output pins and are connected to the arduino digital pins.Having indicator LEDs at the output is optional....though it adds a nice effect and helps in debugging :p

Pin 4 goes to ground and 8 to 5V.

Normally a 10k pot is used as an input for the inverting terminal so that the sensitivity of the senor can be changed.However,I've used two 4.7kΩ resistors instead since I tested it and got a decent range.

For the op-amp connections have a look at the ckt diagram provided...the conncetion for each op-amp is identical.

The male header pins are where the output from the IR sensor array is connected and the female header are where the output of the op-amp board is connected to the arduino.

Note : Since my goal is to detect a black line on a white surface I've made the connections accordingly...if you want to detect a white line on a black surface just switch the connections for the inverting and non-inverting pins.

Step 4: Some Code to Start Out With...

Here's some code to get you started on taking readings from the libraries needed just paste and go!!

What the code does :

  1. Each sensor reading (either 1 or 0) is stored in an array of 5 elements.
  2. readOut() function runs through each array element and save all reading into a 5 digit integer(E.g. 00100)
  3. The integer is returned to the main loop where the reading is displayed.

I'm currently working on the code to use these readings with a PID control filter to use on the line follower robot.

Step 5: More Pictures

Some more pictures...

Improvement tips :

  1. Try and mount the sensor as low as possible to the ground so that you get a good reading and since the sensor will be less affected by ambient light.
  2. Try and add a barrier between each pair (like a heatshrink tube over the IR led) so that each pair isnt affected by the others reading.

So now that you're done with the sensor array the only thing left is mounting it to the chassis and connecting motors..I will update that in another instructable once its done.

P.S : Please vote for this Instructable if you liked it :)

Epilog Challenge VI

Participated in the
Epilog Challenge VI

Battery Powered Contest

Participated in the
Battery Powered Contest