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
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
For this instructables we will need following things :
Arduino uno
IR sensor
Jumper wires
Schmatics
Please refer the shown schmatics and connect everything According to it.
Code
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
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.
When you remove object you will see it gets turned off.