0% found this document useful (0 votes)
20 views

How To Make An IR Object Sensor With Arduino

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

How To Make An IR Object Sensor With Arduino

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

instructables

How to Make an IR Object Sensor With Arduino

by goks_lf

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.

How to Make an IR Object Sensor With Arduino: Page 1


Step 1: 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.

How to Make an IR Object Sensor With Arduino: Page 2


1

1. These are 330 Ohms, you can use either 330 or 220 ohms.

Step 2: IR Transmitter-Receiver Pair

IR LED emits infrared light, means it emits light in the The IR radiation emitted by the emitter is reflected
range of Infrared frequency. We cannot see Infrared from the object is caught by the emitter and a voltage
light through our eyes, they are invisible to human is produced. This is how an object is detected.
eyes. The wavelength of Infrared (700nm – 1mm) is
beyond the normal visible light. We can see them Like all regular LEDs, for the IR Emitter and the
through a camera though. Receiver, the longer leg is the anode and the shorter
one is the cathode.
An IR photo-diode can be used as an IR Receiver.

How to Make an IR Object Sensor With Arduino: Page 3


Step 3: 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.

How to Make an IR Object Sensor With Arduino: Page 4


Step 4: Calibration

Before we move on to the actual code, we need to the Analog In Out Serial from the Example sketches.
calibrate the sensor. This is needed because the Now you can see the values sent from the sensor.
Signal received is in analog form, and we need to You can see the change in values if you bring an
convert that to digital form and use that to turn object in front of the sensor. Using these values set a
ON/OFF the indicator LED. threshold. Use this threshold value to judge whether
there is an object in front of the sensor.
To view the analog values from the sensor, upload

How to Make an IR Object Sensor With Arduino: Page 5


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

Once you have verified the code, upload it to the automatic flushes and many other places.
Arduino. Now, it's time to test it. If you bring an object
in front of the sensor, you should see the LED turn That's All Folks !!! Stay tuned for More!!
on. You can also see the message being displayed
on the Serial Monitor. This means that you have If you have any questions, please leave them in the
made an IR object sensor. comments below !!

This sensor can be used in automatic doors,

How to Make an IR Object Sensor With Arduino: Page 6


How to Make an IR Object Sensor With Arduino: Page 7

You might also like