Introduction: EDGE AVOIDING ROBOT
A very interesting project to start and learn more about microcontroller and IR sensor together moving the motors by initiating motor drivers(we used L293D)
An overview:-
The robot will move forward, backward, right and left anywhere and if that place supposes a table and when it will come near to an edge the robot will automatically sense the edge by the help of IR sensor and it will give impulse to Arduino to handle the rotation of the DC motors by initiating motor driver to act accordingly as per the logic implemented in the code uploaded in Arduino Uno.
Let's start
(the channel name changed to VOICE OF TECHNOLOGY from S_R TRONICS )
Step 1: COMPONENTS
1:-Arduino Uno(Arduino UNO R3)
2:-two ir sensors(Silicon TechnoLabs 2pcs IR Proximity Sensor for line follower and Obstacle sensing Robots.Interface with ARDUINO,AVR,8051,PIC,ARM,MSP430 (Green))
3:-l293d motor driver(Embeddinator's L293D Motor Driving Module)
4:-battery(power bank)(Intex IT-PBB 2000 MAH Power Bank (Black))
5:-jumper wires(Robo India JW-C3 Jumper Wire - 10 Male to Male + 10 Female to Female + 10 Male to Female)
6:-two dc motors(REES52 BOSET BO Motor 100 RPM 2 Pieces + BO Wheel 2 Pieces + BO Motor Clamp with Screws 2 Pieces)
7:-one chassis(Super Jumbo Chasis (Color May Vary))
8:-caster wheels
9:-mini breadboard(KTC CONS Labs Nickel Plated 840 Points Bread Board or Solderless Piecesb Circuit Test Board, White)
Step 2: IR WORKING CONCEPT
we have used IR transmitter and receiver also called photodiodes are used for sending and receiving light. IR transmits infrared lights. When infrared rays fall on any surface except black or many dark surfaces, it’s reflected back and caught by the photodiode and generates some voltage changes. When IR light falls on a black surface, light is absorbed by the black surface and no rays reflect back, resultantly photodiode doesn't receive any light or rays.
Here in this Edge Avoider robot when the sensor senses a white surface then the microcontroller gets 0 as input and when senses black line controller gets 1 as input.
Step 3: IR SENSOR CONNECTION
so we have two IR sensors module...
left IR sensor and right IR sensor which has
VCC,gnd, and operation
VCC is connected to +5v
gnd is connected to gnd
op connect to pin of Arduino Uno.
Step 4: L293D IC CONNECTION TO ARDUINO
if you use l293d ic instead of l293d motor driver.
even it will be easy for connection.
L293D ic has 16pin... 1,8,9 and 16 pin connect to +5v. and 4,5,12,13 pin connect to gnd...
input 1,2,3 and 4pin is connect toArduinoo pin.
The output needs to be connected to the left motor and right motor..
input 1 and 2 is connect for left motor..
and input 3 and 4 is connect for the right motor.
Step 5: CIRCUIT
Two IR sensors.
so left IR sensor op means output pin connects to the.....9pin of Arduino
right IR sensor output pin connected to the....12pin of Arduino
two IR sensor's vcc............connect to +5v
and gnd ...connect to gnd
so l293d motor driver:-
8pin of arduino....connect to.....2pin of l293d
7pin of arduino....connect to.....7pin of l293d
4pin of arduino....connect to.....10pin of l293d
3pin of arduino....connect to.....15pin of l293d
VCC is connected to +5v
and gnd is connected to gnd to the 9v battery.
Step 6: UPLOADING CODE
Copy the code paste in Arduino IDE ,compile ir and run ,if face any problem let us know bin comment section or mail us .
#define LS 9 // left sensor
#define RS 12 // right sensor
/*-------definning Outputs------*/
#define LM1 8 // left motor
#define LM2 7 // left motor
#define RM1 4 // right motor
#define RM2 3 // right motor
void setup()
{
pinMode(LS, INPUT);
pinMode(RS, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
}
void loop()
{
if(digitalRead(LS) && digitalRead(RS))
// Move Forward
{
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if(!(digitalRead(LS)) && digitalRead(RS)) // Turn right
{ digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if(digitalRead(LS) && !(digitalRead(RS)))
// turn left { digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
if(!(digitalRead(LS)) && !(digitalRead(RS)))
// stop
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
}