Wednesday 10 April 2013

A LIGHT FOLLOWER ROBOT

A LIGHT FOLLOWER ROBOT



The main purpose of this project is to design a robot which would follow the path of higher luminescence across all directions.It is based on the principle that resistance of a LDR changes with the amount of light falling on it.

The light following robot is a mobile machine which is capable of detecting and following the light source on the traveling path. It is developed without the help of a micro-controller for providing easier connections and understanding of the circuit. It requires fewer numbers of electronic components and very cost-effective as well.

The concept of this light following robot is very simple. It includes two photodiodes, one on the right and other on the left. When the light falls on the right photodiode, the robot will move on the right side. Similarly, the robot will move on the left side when the light falls on the left photodiode.



Introduction:


Now the question is, how can we start our project? We need to learn how electronics and mechanical structure work together. We will go forward step by step. If you want to make a Light following robot, you need to have some basic knowledge of the following things:



Electronics:

LDR (Light dependent resistor).
H-Bridge Driver.
L293D ( Motor Driver)
Ardunio Uno (MCU)
Battery

Mechanical:

Wheel.
Robot structure.
Ball caster.
Micro Metal Gear Motor.

For this project we have used Arduino Uno as the main processor unit. It is an 8-bit microcontroller. It has 32 Kbytes of flash memory. Enough memory space to do this kind of project, I think.




CONSTRUCTION AND WORKING

motor driver(L293D) circuit



rectifier circuit
Connect a 9V battery to the breadboard with the help of a battery holder. The positive power supply is passed to the IN of IC 7805 (1), and sent out through the OUT (3). The negative power supply is sent to the GND (2) connection of IC 7805. In between, two capacitors (C1 & C2) are connected to the IN and OUT of IC 7805 respectively. As a result of this process, 5V of current is obtained.

Now, connect an IC LM358 in the breadboard. As it is a voltage comparator, it will predict the output from the photodiodes based on the input voltage. For instance, let us consider that the voltage at 3rd pin is more than or equal to the voltage at 2nd pin. At this time, the 1st pin of IC LM358 will be high or else it will stay low. A 10K resistor is coupled with each photodiodes. Then, place an IC L293D in the breadboard, and join the 2nd and 15th pin of it with 1st pin of IC LM358. In between this connection, include a LED with the 10K resistor.

The four – core wire of left motor is connected to the 3rd & 6th pin of IC L293D, while the right motor is attached with 11th & 14th pin. The two 10cm wheels are mounted with the motors. Acastor wheel is included at the front of the robot for balanced and comfortable movements. A power supply of 5V is applied to the 1st, 7th, 8th, 9th, & 16th pins. The remaining 4th, 5th, 10th, 12th, & 13th pins are connected to the ground.

After finishing all the circuit connections, place the robot in the dark room. Connect the 9V battery and power the robot. Now, show the light in front of the robot, and it will follow the light wherever it goes.

LOCOMOTION


The locomotion system we are using here is the differential drive. It is a basic design with two motors, two wheels and a castor wheel as shown in line follower post. The chassis is a ready-made steel chassis that can be bought from robotics shop.




SENSORS


LDR SENSORS

LDRs or Light Dependent Resistors are very useful especially in light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000 000 ohms, but when they are illuminated with light resistance drops dramatically.

The above schematic diagram is an example of a light sensor circuit :

When the light level is low the resistance of the LDR is high. This prevents current from flowing to the base of the transistors. Consequently the LED does not light.

However, when light shines onto the LDR its resistance falls and current flows into the base of the first transistor and then the second transistor. The LED lights.

The preset resistor can be turned up or down to increase or decrease resistance, in this way it can make the circuit more or less sensitive.



ldr sensor and its orientation





















This is the most important part of the robot. We have used here a three sensor layout which enables the robot to sense any light source in front of it. Of course, there can be several more different layouts to optimize the performance of the robot. Below is the picture of the sensory circuit mounted on the robot.

Let us mark these sensors as left(L), right(R) and center C) sensors. The ultimate goal of our code is to find which sensor receives maximum intensity and to face the robot in that direction. Below diagram shows the circuitry in the sensor circuits:

Each sensor has to be provided a 5V Vcc supply and a data(D) output has to be taken out from it. Three sensor circuits as shown in fig 2 will complete our sensory part of the robot.

A COMPLETE CIRCUIT DIAGRAM OF LIGHT FOLLOWER









CODES FOR LIGHT FOLLOWER USING ARDUINO UNO





int motorLEFTpin1 = 5;              //define digital output pin no.
int motorLEFTpin2 = 6;              //define digital output pin no.
int motorRIGHTpin1 = 10;
int motorRIGHTpin2 = 11;
      
int ldrs1=A0; 
int ldrs2=A1;
int ldrs3=A2;

int ldrs11=0; 
int ldrs22=0;
int ldrs33=0;


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

  pinMode(ldrs1,INPUT);
  pinMode(ldrs2,INPUT);
  pinMode(ldrs3,INPUT);
  
  pinMode(motorLEFTpin1,OUTPUT);        //set pin 5 as output
  pinMode(motorLEFTpin2,OUTPUT);        // set pin 6 as output
  pinMode(motorRIGHTpin1,OUTPUT);       // set pin 10 as output
  pinMode(motorRIGHTpin2,OUTPUT);        // set pin 11 as output
  delay(100);
}        


void loop()

  
         // read the input pin


  Serial.println(ldrs1);
  Serial.println(ldrs2);
  Serial.println(ldrs3);

  Serial.println("\t");
  Serial.println("\t");
  ldrs11 = analogRead(ldrs1);
    ldrs22 = analogRead(ldrs2);
    ldrs33 = analogRead(ldrs3);
   
  
   if ( ldrs33<200 && ldrs22<200 && ldrs11<200 || ldrs22<200 ) {                  //move straight
    
    digitalWrite(motorLEFTpin1,HIGH);
    digitalWrite(motorLEFTpin2,LOW);
    digitalWrite(motorRIGHTpin1,HIGH);
    digitalWrite(motorRIGHTpin2,LOW);
    


else if ( ldrs11<200) {                  //move left
    
    digitalWrite(motorLEFTpin1,LOW);
    digitalWrite(motorLEFTpin2,LOW);
    digitalWrite(motorRIGHTpin1,HIGH);
    digitalWrite(motorRIGHTpin2,LOW);
    delay(200);
  

             
    }
     else if (ldrs33<200 ) {                  //move right
    
             digitalWrite(motorLEFTpin1,HIGH);
             digitalWrite(motorLEFTpin2,LOW);
             digitalWrite(motorRIGHTpin1,LOW);
             digitalWrite(motorRIGHTpin2,LOW);
         
    } 
else if ( ldrs33>800 && ldrs22>800 && ldrs11>800 ) {                 
 //no light, move 360 degree  and search for light
    
    digitalWrite(motorLEFTpin1,HIGH);
    digitalWrite(motorLEFTpin2,LOW);
    digitalWrite(motorRIGHTpin1,LOW);
    digitalWrite(motorRIGHTpin2,HIGH);

  
  }
  
}