Introduction: LIGHT OBEYING ROBOT

About: Voice Of Technology·Wednesday, 22 April 2020· Welcome to our page ,here you all get some exciting engineering project video clips and if you follow the link to the YouTube you will get the total tutorials of…

LIGHT CAN CONTROL ROBOTIC MOVEMENT?

YES, a big YES,

BUT HOW?

Follow the instructions thoroughly you will learn within 10 minutes.

A simple very easy project is "LIGHT FOLLOWING ROBOT"

it is also one of the best projects for college students to present in the final year or for competitions.we have used an LDR or you can say light resistor so that we can take it as an input which can sense the intensity of light and the microcontroller is programmed as such upon certain values and parameters of the light sensed by the resistor it will drive the motor drivers to move the wheels forward, backward, right and left.

*Again notifying our channel name changed from "S_R TRONICS" to "VOICE OF TECHNOLOGY".

Step 1: COMPONENTS

1:-arduino uno(Arduino UNO R3)

2:-jumper wires(Robo India JW-C3 Jumper Wire - 10 Male to Male + 10 Female to Female + 10 Male to Female)

3:-light resistor(KTC CONS Labs 10 Pcs LDR - 5mm Light Dependent Register/Photo resistor (Pack of 10))

4:-l293Dmotor driver(l293d ic)(Embeddinator's L293D Motor Driving Module)

5:-one chassis(Super Jumbo Chasis (Color May Vary))

6:-9v battery with battery holder

7:-two wheels with caster wheel

8:-mini breadboard(KTC CONS Labs Nickel Plated 840 Points Bread Board or Solderless Piecesb Circuit Test Board, White)

9:-dc motor(REES52 BOSET BO Motor 100 RPM 2 Pieces + BO Wheel 2 Pieces + BO Motor Clamp with Screws 2 Pieces)

Step 2: LDR CONNECTION

LDR has two pins:

one pin connects to gnd

and another pin is connected to the input of Arduino.

even you connect it by 10k ohm resistor to +5v.

Step 3: CIRCUIT DIAGRAM

Two light resistors are used in the project, one is right LDR another is left LDR which are connected to the Arduino UNO as input.

*We are here using L293D chip, not the driver but all things are the same for the driver also.

a0 pin of Arduino connects to.......left sensor LDR.

a1 pin of Arduino connect to......right sensor pin LDR

L293D MOTOR driver:---

4,5,6,9 pin of Arduino is connected to l293d motor driver.
4pin of Arduino is connected to 2pin of l293d

5pin of Arduino is connected to 7pin of l293d

6pin of Arduino is connected to 10pin of l293d

9pin of Arduino is connected to 15pin of l293d and

VCC is connected to +5v

ground to the gound of Arduino.

Step 4: CODING

Just copy and paste the code compile it and upload and enjoy the new robot.

1st compile thenupload to arduino board..

int motor_left[] = {4, 5};

int motor_right[] = {6, 9};

const int RightSensor = A0; // Read the right sensor

const int LeftSensor = A1; // Read the left sensor

// Variable definitions

int SensorLeft; // This stores the value of the Left Sensor pin to use later on in the sketch

int SensorRight; // This stores the value of the Right Sensor pin to use later on in the sketch

int SensorDifference; // This value is used to determine the difference between the Left and Right

void setup() {

int i; for(i = 0; i < 2; i++){ pinMode(motor_left[i], OUTPUT); pinMode(motor_right[i], OUTPUT); }

pinMode(LeftSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.

pinMode(RightSensor, INPUT); // Defines this pin as an input. The Arduino will read values from this pin.

digitalWrite(A0, HIGH); // Enables an internal pullup resistor

digitalWrite(A1, HIGH); // Enables an internal pullup resistor

Serial.begin(9600); // Enables a serial connection through the Arduino to either USB or UART (pins 0&1). Note that the baud rate is set to 9600

Serial.println(" \nBeginning Light Seeking Behavior"); // Placed at the very end of void Setup() so that it is runs once, right before the void Loop()

}

// the loop() method runs over and over again,

// as long as the Arduino has power

void loop() {

SensorLeft = 1023 - analogRead(LeftSensor); // This reads the value of the sensor, then saves it to the corresponding integer.

SensorRight = 1023 - analogRead(RightSensor); // This reads the value of the sensor, then saves it to the corresponding integer.

SensorDifference = abs(SensorLeft - SensorRight); // This calculates the difference between the two sensors and then saves it to an integer.

// This section of the sketch is used to print the values of the

// sensors through Serial to the computer. Useful for determining

// if the sensors are working and if the code is also functioning properly.

Serial.print("Left Sensor = "); // Prints the text inside the quotes.

Serial.print(SensorLeft); // Prints the value of the Left Sensor.

Serial.print("\t"); // Prints a tab (space).

Serial.print("Right Sensor = "); // Prints the text inside the quotes.

Serial.print(SensorRight); // Prints the value of the Right Sensor.

Serial.print("\t"); // Prints a tab (space).

// This section of the sketch is what actually interperets the data and then runs the motors accordingly.

if (SensorLeft<500 && SensorRight<500) { motor_stop();

Serial.println("Stop"); }

if (SensorLeft > SensorRight && SensorDifference > 75 && SensorLeft>500 && SensorRight>500) { // This is interpreted as if the Left sensor reads more light than the Right Sensor, Do this:

turn_left();

Serial.println("Left"); // This prints Left when the robot would actually turn Left.

}

if (SensorLeft < SensorRight && SensorDifference > 75 && SensorLeft>500 && SensorRight>500) { // This is interpreted as if the Left sensor reads less light than the Right Sensor, Do this:

turn_right();

Serial.println("Right"); // This prints Right when the robot would actually turn Right.

}

else if (SensorLeft>500 && SensorRight>500 && SensorDifference < 75) { // This is interpreted as if the difference between the two sensors is under 125 (Experiment to suit our sensors), Do this:

drive_forward();

Serial.println("Forward"); // This prints Forward when the robot would actually go forward.

}

Serial.print("\n");

} void motor_stop(){ digitalWrite(motor_left[0], LOW); digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW); digitalWrite(motor_right[1], LOW); }

void drive_forward(){ digitalWrite(motor_left[0], HIGH); digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], HIGH); digitalWrite(motor_right[1], LOW); }

void drive_backward(){ digitalWrite(motor_left[0], LOW); digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], LOW); digitalWrite(motor_right[1], HIGH); }

void turn_left(){ digitalWrite(motor_left[0], LOW); digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], HIGH); digitalWrite(motor_right[1], LOW); }

void turn_right(){ digitalWrite(motor_left[0], HIGH); digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW); digitalWrite(motor_right[1], HIGH);

}

*if you face any problem feel free to reach us comment below and or mail us .

Thank you.