IR Proximity Sensor Interfacing With Arduino Board

Interfacing IR Sensor With Arduino UNO.

You will learn how to use the Infrared Sensor to detect objects in close proximity

IR-Proximity-Sensors.webp

Through below image you can understand the working of IR Proximity sensor.

IR-SENSOR-WORKING

Components Required:

  1. One Arduino UNO
  2. Computer with Arduino IDE
  3. USB to Arduino connecting Cable
  4. Jumper Wires
  5. IR Sensor

 

Circuit Diagram:

ir-sensor-interfacing-with-arduino

 

Steps To Follow::

  1. Establish the Circuit Mentioned.
  2. Open Arduino IDE.
  3. Click on File.
  4. Go to New. – A new File will open
  5. Remove the Pre-Written code..
  6. Paste the code given in the “CODE Section”
  7. Check whether your UNO has been detected by the ID by going to Tools.
  8. Click on Port – Select the COM-Port on which Arduino UNO is detected.
  9. Verify the Sketch by Clicking on the TICK icon.
  10. Once, the sketch is verified, Upload the sketch using the ARROW icon.

 

Code:

const int ProxSensor=2;
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
//Pin 2 is connected to the output of proximity sensor
pinMode(ProxSensor,INPUT);
}
void loop() {
if(digitalRead(ProxSensor)==HIGH) //Check the sensor output
{
digitalWrite(13, HIGH); // set the LED on
}
else
{
digitalWrite(13, LOW); // set the LED off
}
delay(100); // wait for a second
}

 

Leave a comment