Arduino Obstacle Avoiding Sensor Tutorial | Arduino IR Sensor Tutorial

by Utsource in Circuits > Arduino

838 Views, 0 Favorites, 0 Comments

Arduino Obstacle Avoiding Sensor Tutorial | Arduino IR Sensor Tutorial

Screenshot_20191115-111308__01.jpg
Hi guys in this instructables we will learn how to interface a obstacle avoiding IR sensor to arduino and with this sensor we can detect obstacles. If there will be an obstacle then led will glow otherwise not.

Things You Need

Km5Zu-2RIncAUweU7uG7IhyWPySZ0SqIgAI0-vk9w7767_IkthCPCcsirj2GGmXF4IdQDg8UVpHVLVM6CXnzFsG1hnAdSkK7BIhIOtEldXoZiDsvzsPo-6o0rD6Mda7UyOE=w456-h323-nc.png
1573796961852.jpg

For this instructables we will need following things :

Arduino uno

IR sensor

Jumper wires

Schmatics

images(109).jpg
Please refer the shown schmatics and connect everything According to it.

Code

images(101).jpg

Please copy the following code and upload it to your arduino Board :


const int IR_Sensor=2;

void setup() {

// initialize the digital pin as an output.

// Pin 13 has an LED on Arduino boards:

pinMode(13, OUTPUT);

//Pin 2 is connected to the output of IR_Sensor

pinMode(IR_Sensor,INPUT);

}

void loop() {

if(digitalRead(IR_Sensor)==HIGH) //Check the sensor output

{

digitalWrite(13, HIGH); // set the LED on

}

else

{

digitalWrite(13, LOW); // set the LED off

}

delay(1000); // wait for a second

}

Testing the Obstacle Avoiding Sensor

Screenshot_20191115-111308__01.jpg
20191115_112532__01.jpg
Place the object in front of IR proximity sensor and observe the change in LED connected to Pin 13 (on board LED)
When you remove object you will see it gets turned off.