Interfacing Ir sensor with Arduino

SENSOR:
     Sensor is an electronic device which converts physical quantity(temperature,object....)into electrical quantity(voltage or current). 
  
      Okay...Now we are going to see how to detect the obstacle using arduino hardware.

Hardware Required:

  • Arduino uno
  • IR sensor
  • Light Emitting Diode(LED)
  • Bread board
  • Connecting wires
Connections
  1. Connect Arduino 5v pin to IR sensor Vcc.
  2. Connect Arduino GND pin to IR sensor GND.
  3. Connect Output pin of sensor to arduino pin 7.
  4. Connect Anode(+) of LED with pin 13 and Cathode(-) with arduino GND pin.
IR Sensor:
        An Infrared sensor is an electronic device,that emits in order to sense some aspects of the surroundings.An ir sensor can measure the heat of an object as well as detects the motion.

Working Principle:
     A transmitter is transmits the infrared light signal ,when object is presented a transmitting signal is reflected then a receiver receive the reflected signal.Then it convert physical quantity into electrical quantity. 




                                               Turn ON your device



Working....
            
                                                IR sensor interfaced with arduino.


                                               Arduino IDE serial monitor
  Arduino code ↓↓
int LED = 13; // Use the onboard Uno LED
int obstaclePin = 7; // This is our input pin
int hasObstacle = HIGH; // HIGH MEANS NO OBSTACLE
void setup() {
pinMode(LED, OUTPUT);
pinMode(obstaclePin, INPUT);
Serial.begin(9600);
}
void loop() {
hasObstacle = digitalRead(obstaclePin); //Reads the output of the obstacle sensor from the 7th PIN of the Digital section of the arduino
if (hasObstacle == LOW) //LOW means something is ahead, so illuminates the 13th Port connected LED
{
Serial.println("Stop something is ahead!!");
digitalWrite(LED, HIGH);//Illuminates the 13th Port LED
}
else
{
Serial.println("Path is clear");
digitalWrite(LED, LOW);
}
delay(200);
}
view raw Arduino code hosted with ❤ by GitHub

Prototyping Model

            When IR sensor is detect the obstacle the led will glow.

                     
THANK YOU FOR WATCHING!!!



No comments:

Post a Comment