How To Make An IR Object Sensor With Arduino
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:
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.
Arduino Uno
IR transmitter
IR Receiver
Resistors 220 Ohm (2 nos)
LED
BreadBoard
1. These are 330 Ohms, you can use either 330 or 220 ohms.
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.
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.
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
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);
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 !!