Introduction: How to Make an IR Object Sensor With Arduino

Picture of How to Make an IR Object Sensor With Arduino

An IR sensor is an electronic instrument used to sense certain characteristics of its surroundings by either emitting and/or detecting Infrared radiation. Infrared sensors can also measure heat emitted by an object and detect motion. Few of the key applications of the IR sensor are:

  • Night Vision Devices
  • Line Follower Arrays
  • Motion Detectors

One of the popular uses of the IR sensor in the DIY Electronics Community is for the line follower robots and ping sensors. So, in this Instructable I'll show you how to make an IR sensor which can detect objects and can be used in simple applications.

I'll also be using this same IR sensor in a few upcoming projects.

Step 1: Components Required

Picture of Components Required

These are the things you need to make an IR object sensor:

  • Arduino Uno
  • IR transmitter
  • IR Receiver
  • Resistors 220 Ohm (2 nos)
  • LED
  • BreadBoard

With all these, we're ready to get going.

Step 2: IR Transmitter-Receiver Pair

Picture of IR Transmitter-Receiver Pair

IR LED emits infrared light, means it emits light in the range of Infrared frequency. We cannot see Infrared light through our eyes, they are invisible to human eyes. The wavelength of Infrared (700nm – 1mm) is beyond the normal visible light. We can see them through a camera though.

An IR photo-diode can be used as an IR Receiver. The IR radiation emitted by the emitter is reflected from the object is caught by the emitter and a voltage is produced. This is how an object is detected.

Like all regular LEDs, for the IR Emitter and the Receiver, the longer leg is the anode and the shorter one is the cathode.

Step 3: The Circuit

Picture of The Circuit

Follow the schematic to make the circuit. Here, the voltage produced by the IR Receiver is converted from analog to digital and is used as a reference to know whether the object is detected or not. This pic can be called as the signal pin. An LED is used to indicate the detection of the object.

Step 4: Calibration

Picture of Calibration

Before we move on to the actual code, we need to calibrate the sensor. This is needed because the Signal received is in analog form, and we need to convert that to digital form and use that to turn ON/OFF the indicator LED.

To view the analog values from the sensor, upload the Analog In Out Serial from the Example sketches. Now you can see the values sent from the sensor. You can see the change in values if you bring an object in front of the sensor. Using these values set a threshold. Use this threshold value to judge whether there is an object in front of the sensor.

Step 5: The Code

const int analogInPin = A0;  // Analog input pin that the receiver is attached to

int sensorValue = 0; // value read from the receiver

void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); //initialize the indicator LED: pinMode(13, OUTPUT); }

void loop() { // read the analog in value: sensorValue = analogRead(analogInPin);

// print the results to the serial monitor: Serial.print("\nsensor = "); Serial.print(sensorValue); //the threshold found fron analog In Out program was when object is detected, the sensor value is below 100 //set the threshold whihc you get //the threshold varies for different sets of emitter-receiver pairs if(sensorValue < 100){ //checks if object is there or not digitalWrite(13, HIGH); Serial.print("\nObject Detected"); } else{ digitalWrite(13, LOW); Serial.print("\nNo object in Front"); } delay(500); }

Step 6: Uploading and Testing

Picture of Uploading and Testing

Once you have verified the code, upload it to the Arduino. Now, it's time to test it. If you bring an object in front of the sensor, you should see the LED turn on. You can also see the message being displayed on the Serial Monitor. This means that you have made an IR object sensor.

This sensor can be used in automatic doors, automatic flushes and many other places.

That's All Folks !!! Stay tuned for More!!

If you have any questions, please leave them in the comments below !!

Comments

BraddJ (author)2017-11-09

Could you post break down pictures of the wires and components being connected individually as I am unable to make out where each wire and component is connected?

About This Instructable

1,281views

24favorites

License:

Bio: My team has developed a new product. PLEASE CHECK IT OUT ON INDIEGOGO AND SHOW YOUR SUPPORT. CAMPAIGN LINK: https://igg.me/p/2165733/x ... More »
More by goks_lf:Double Cheese Corn WrapChoco-Cheese ToastFancy Hand Band
Add instructable to: