# The \$40 Line Follower - Step 3A: Electronics (Circuit Explanation)

## The Electronics

### The Circuit explanation

In this part of the tutorial I will explain the circuit and the different parts used by the robot.
As told before, the robot uses a combination of LDRs and LEDs to sense the presence to a line. An LDR is a resistor whose resistance is proportional to the light falling on it- greater the light, lesser the resistance and visa-versa. The basic principle underlying this project is that objects light in colour radiate the light falling on them while dark coloured objects donâ€™t. So when the sensors are above the black line the light emitted by the LED is not radiated by the floor, hence the resistance of the LDR increases. The opposite happens when the robot back on the white surface.

In our robot the LDR is used part of a voltage divider circuit. To know more about voltage dividers and LDRs visit www.doctronics.co.uk/voltage.htm The circuit diagram of the voltage divider used in this project is given below

The resistor whose value is 20K is a potentiometer. A potentiometer (pot or preset) is a resistor whose resistance can be changed. In our project, we will be using 20k presets, that is, we will use presets whose resistance can be changed from 0K to 20K.
When the robot is on white surface the light emitted by the LEDs fall on the LDRs and decreases its resistance. This in turn reduces the voltage at Vout. When the robot is on the black line, the light emitted by the LEDs does not reach the LDRs, hence its resistance increases. This in turn increases the voltage at Vout.
During both the cases it is necessary to adjust the 20K preset in such a way that, when the robot is on white surface, voltage at Vout is <0.8V (so that the voltage at the emitter of the transistor is LOW) and when the sensor is on the black line the voltage is >0.8V (so that the voltage at the emitter of the transistor is HIGH).
For controlling the two DC motors, I have used the L293D motor driver. The reason I used this is that it has high noise immunity (that is, it considers voltages upto 1.7V as LOW), perfect for a robot which deals with analog signals.
The pins 4, 5, 12 and 13 are connected to ground. Pin 8 is the motor power supply pin and is connected to Vcc (9V) along with Pins 1, 16 (the two enable pins) and Pin 9. The left and right motors are connected to Pins 3, 6 and Pins 14, 11 respectively. Pin 2 (Input A), Pin 7 (Input B) and Pin 15 (Input A), Pin 10(Input B) are the input pins for controlling the left and right motor respectively. The truth table for controlling the motors is given below

Note in all the above cases the voltage at the enable pins is high

The complete circuit of the robot is given below.

In both the sides of the robot two sensors are used to sense the presence the line. The output of both the sensors of each side are connected together and connected to an LED. So that, the LED glows even when one of the sensors detects the line. The output of the left sensor is connected to Input A (Pin 2) of the left motor and the right sensor to Input A (Pin 15) of the right motor. The other two inputs are connected to Vcc.
When the robot is on white surface only one (Pin 7 and 10) input pin in each channel is high. The Pins 2 and 15 are low as the sensors are on white surface. Hence this makes the robot move forward. When the left sensor is on the line, Pin 2 is high. But Pin 7 is also high. Hence the left motor is switched off as both the inputs are HIGH(refer to the truth table above). But the right motor is still turning forward. This brings the robot back on the white surface.
Similarly when the right sensors are on the line, the right motor is switched off until the robot is back on the white surface.
This circuit works fine for black line following and using the robot as a photovore and obstacle avoider, for following white line and for using the robot as a photophobe, there is a slight change in the circuit. The left sensor output is connected to Pin 7 and right sensor output to Pin 10. Pins 2 and 15 remain unconnected. The rest of the circuit remains unchanged.
When the robot is on black surface (when following white lines), the input pins 2 and 15 are high. This makes the motors turn forward. When the left sensors are on the line the output goes low and stops the motor until the sensors are back on the black surface. Similarly, when the right sensors are on the line, the right motor is stopped.
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}