Here are the parts you will need:
| Sr. No.
||220Ω 1/4W Resistors.
||20KΩ Potentiometers (Use presets)
||Light Dependent Resistors
||Use four 1.5 V batteries. With this you will get 6V. Alternatively you can use four 1.2V batteries to get 4.8V
||Use a 9V battery
||The L293D is a motor driver. See http://focus.ti.com/lit/ds/symlink/l293.pdf for the datasheet. Also use a 16-pin IC base if you are soldering the circuit on a PCB.
||DC Motors. I used 200rpm DC motors. (12V, 2A)
||Breadboard or PCB
||A general purpose PCB can be used to solder the components. Alternatively you can also use a breadboard. I’ve used a PCB
The circuit can be constructed on a bread board or soldered on to a general purpose PCB. Make sure that the wires connecting the LEDs and LDRs are long enough since they need to “look” at the line which the robot will follow. Solder the 16-pin IC base to the PCB and then fix the L293D to that.
Here’s a photograph of the circuit excluding the LEDs and LDRs:
The two connectors on the left are for the motors. I did not solder the connections to the motors directly. Instead, I used 2-pin female RMC connectors for the motors. On the PCB I connected the outputs on the L293D to berg strips (use two pairs of pins – one for each motor). With this you can change the polarity of the motors if needed.
Once the circuit is done, you will need to put the motors, wheels and circuits together. Here’s what you will need:
- Chassis – I used a base from a Meccano Set. You could choose any appropriate material you like (maybe a thin sheet of wood).
- Wheels (see the photograph of the robot below).
- Caster Wheel (spherical) – This is a free moving wheel fixed to the front of the robot.
- Clamps – To fix the motors to the chassis.
In addition to this, I covered the LEDs and LDRs using plastic LED holders. This protects the LDRs from the light of the room (LDRs are extremely sensitive). Next I paired an LED with an LDR and taped the two together. This is what the sensor section looks like:
The sensors were mounted using two cardboard strips. I made two grooves on each strip – one for each LED-LDR pair.
Fix the motors using clamps and then fix the wheels on to them. Next place the PCB on the top of the base. If you are using a metal base, make sure you insulate the bottom of the PCB with some tape. Fix the caster wheel at the front using spacers between the chassis and the wheel. Finally place the batteries and you’re done.
Here are photographs of the completed robot:
It shouldn’t take you more then a few hours to finish if you are not new to soldering components. In the workshop I conducted, there were participants who were soldering for the first time and they were able to complete the robot successfully in 9 hours (spread over two days).
How Does It Work?
First, lets understand how the sensors work. For that, we need to first look at how an LDR changes its resistance depending on how much light falls on it.
The LDR is basically a semiconductor. If you have studied about semiconductors, you will be familiar with the Band Model. We know that a semiconductors crystal has two main energy bands where electrons (or holes) can exist. These are the valence band and the conduction band. The electrons must exist in the conduction band for conduction to take place. However, an Energy gap prevents electrons from moving to the conduction band freely. The electrons need energy to jump to the conduction band. This energy is usually given in the form of electrical energy i.e. by connecting the semiconductor across a voltage source. The energy gap and the number of electrons in the conduction band define the resistance of the material. When light falls on an LDR, the electrons gain energy from this light and move into the conduction band causing the resistance to decrease.
Thats how the LDR works. Light falls on the LDR when light from the LED is reflected off the white surface. Little or no light falls when the sensors are on the black line since reflection won’t take place. Now lets see how we can use this as a sensor. Take a look at the circuit again. The LDR and the potentiometer form a voltage divider system:
The voltage at the point between the potentiometer and LDR is connected to the L293D IC. Lets look at two cases.
- Case 1: When the sensor is placed over the black line, no light falls on the LDR. It thus has a very high resistance, typically in the MΩ range. Suppose the resistance of the LDR is 1MΩ. Thus the voltage at the node is:
- Case 2: When the sensor is placed over the white line, light falls on the LDR. Therefore its resistance is quite low, possibly 1 or 2Ω. Thus the voltage at the node is equal to:
Hence the sensors give a Logic 0 when they are above the black line and a Logic 1 when on the white surface.
Finally, lets look at the L293D IC. Here’s a schematic of the chip:
Ignore the insides of the chip. Lets look at what the pins are for. The pins EN1, IN1, IN2, OUT1 and OUT2 control one of the motors while the pins EN2, IN3, IN4, OUT3 and OUT4 control the other. Here’s how it works -
- EN1 and EN2 are enable pins. Setting these to Logic 1 (i.e. 5V) enables control to the motor. If these are kept at Logic 0, the motors will not run.
- IN1 and IN2 control the motors direction of rotation. If IN1 = 1 and IN2 = 0, the motor will rotate in one direction and if the inputs are switched, the motor will rotate in the opposite direction. The control signals to the motors are given through OUT1 and OUT2. If IN1 = IN2 = 0 then OUT1 and OUT2 will both have 0V and the motor is free to run. This means that if the robot is moving while this signal is given, it will still move due to its inertia. However, if IN1 = IN2 = 1, OUT1 and OUT2 will both have 10V and the motor is prevented from rotating. This can be used for a braking action.
- The pin Vcc is connected to 5V and Vss is connected to 10V. The latter is used to drive the motor. The L293D has four ground connections.
Suppose EN1, IN1, IN2, OUT1 and OUT2 control the left motor and EN2, IN3, IN4 and OUT3 and OUT4 control the right one. Since the robot isn’t going to perform any complicated line following, we’ll make sure that the motors always cause the robot to move forward. For this we have set IN1 and IN4 to Logic 1 and IN2 and IN3 to logic 0. Connect the EN1 and EN2 pins to the voltage divider system formed by the LDRs and the potentiometers. The left sensor is connected to EN1 while the right sensor is connected to EN2.
Having understood how one can use an L293D, lets see how the robot actually follows a line. When the black line turns towards the right, the right sensor moves on the black line. This causes the sensors to give a Logic 0 at EN2 causing the right motor to stop. The left motor continues running. This causes a right turn. The turning causes the robot to align itself on the line again and now both sensors will be on the white surface and both motors will now run causing the robot to move forward.
Thats how this line follower works. Simple isn’t it? Try it yourself and feel free to comment if you have any questions, suggestions or videos/pictures of your own robots. I have attached the presentation I made for the workshop (check the sidebar on the right). Hope you have fun building it :)
Here is what you do if you want the robot to work on a white line – You add a NOT gate before sending the signal to the chip. So the schematic will change to the following:
Note the two NOT gates (triangles with a small circuit at the apex). Here is how this works. A NOT gate basically reverses it’s input. If you give a value of 5V, the gate will output 0V. Similarly giving a value of 0V will output a value of 5V. So in this case, the motors will move when the sensors are on the black surface. The motors will stop when the sensors are over the white line (that is, reverse/NOT of the original circuit).
I have made an improved version of this robot. This one requires you to make your own PCB. It is also a stronger design. Check it out here: http://wp.me/pRhUf-d0