loading
I made this light following robot some time ago. It's a really simple robot with simple parts.
 
PARTS:

arduino uno
3 photoresistors
3  2.2k resistors
 jumper cable wires 
2  servos (continuous 360 rotation)
9v battery






Step 1:

First, take a piece of cardboard, or something that you could use as a base.

Then, place an arduino uno on it.

Also, place 2 servos on the back of the cardboard.

*You can use double sided tape to do so.

 To test the servos use the following code:

#include <Servo.h>

Servo servo;

void setup()
{
  servo.attach(12);
}

void loop()
{
  servo.write(0);
}

Step 2:

Now, if you have tested the servos, then it's time to test the photoresistors!
 
First, take a photoresistor and connect one side to the vcc, or you can also connect it to pin 3. 

Connect the other side to the 2.2k resistor and connect the resistor to gnd. 
 
Connect the same side to pin A0.

Test this code if you are using pin 3:

int sensor1=3; //  vcc pin
int input1=0;
int LDRvalue=0;
int light_sensetivity=500;
void setup()
{
  Serial.begin(9600);
  pinMode(sensor1,OUTPUT); 
  digitalWrite(sensor1,HIGH);
}
void loop()
{
  LDRvalue = analogRead(input1);
  Serial.println(LDRvalue);
  delay(50);
}

test this if you are using vcc
 
int input1=0;
int LDRvalue=0;
int light_sensetivity=500; // for further use
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  LDRvalue = analogRead(input1);
  Serial.println(LDRvalue);
  delay(50);
}


Step 3:

Now it's a time to put everything together.

First, connect the servos to the arduino uno:
 red = vcc ,black = gnd, white = 12 or 13 for servo1 12 and for servo 2 13

Connect first side of the photoresistor1 to pin3, photoresistor2 to pin2, photoresistor3 to pin4. 

Connect second side of the photoresistor1 to pin A1, photoresistor2 to pin A2, photoresistor3 to pin A0.

Connect all of the second sides to 2.2k resistors and the resistors to gnd.


To support the robot, we need to put something under it so it can move without any problems! 
 
You can use anything that can support the robot, like a wheel, but in this case, i have used two bottle caps.
 
Use a duct tape to connect the bottle caps.

Now place them under the robot using double sided tape.

Use this code to start your own light following robot :

#include ;
Servo servo1;
Servo servo2;
int sensor1=3;
int input1=1;
int sensor2=2;
int input2=2;
int sensor3=4;
int input3=0;
int s1ldrvalue=0;
int s2ldrvalue=0;
int s3ldrvalue=0;
void setup ()
{
   pinMode(sensor1,OUTPUT);
     digitalWrite(sensor1,HIGH);
     pinMode(sensor2,OUTPUT);
     digitalWrite(sensor2,HIGH);
     pinMode(sensor3,OUTPUT);
     digitalWrite(sensor3,HIGH);
    servo1.attach(12);
   servo2.attach(13);
}
 
  void loop()
  {
    s1ldrvalue = analogRead(input1);
   s2ldrvalue = analogRead(input2);
   s3ldrvalue = analogRead(input3);
     servo1.write(90);
   servo2.write(90);
  {
   if(s1ldrvalue < 500)                                  
  {
    servo1.write(0);
    servo2.write(180);
    delay(500);
  }
  else
  {
  if(s2ldrvalue < 500)                                  
  {
    servo1.write(0);
    servo2.write(0);
    delay(500);
}
  else                                 
  {
   if (s3ldrvalue < 500)                                
  {
    servo1.write(180);
    servo2.write(180);
   delay(500);
}
    else;                                 
    }}}}




<p>What happens at noon when the sun is directly overhead?</p>
<p>It's a light following robot so basically it follows the light. now, in order to start the simple task you need a dark place so it doesn't matter if it's morning , noon or night. In order to make the robot work you need to put it in a dark place and then you can use a light to start the task.</p>

About This Instructable

3,159views

22favorites

License:

More by robotuck_98:Light Following Robot (Lighttode) Obstacle Avoider Robot using Relay Board 
Add instructable to: