Instructables
Picture of Arduino IR signal detector

This Instructable will show you how to use your Arduino module to detect whether a flashing IR signal is present.

This could be useful in IR tracking, where you don't want to track the brightest IR object but the one pulsing at a certain frequency.

 
Remove these adsRemove these ads by Signing Up

Step 1: Basic Materials/Layout

Picture of Basic Materials/Layout
draw1jpg.jpg
Materials
  1. 10k Ohm resistor
  2. IR Phototransistor
  3. Hookup wire

Circuit Layout (refer to Drawing)

Simply connect the Phototransistor and Resistor in series.Connect the emitter pin of the Phototransistor (long leg) to GND and the collector pin (short leg) to the resistor which we will connect to the 5v pin of the Arduino.

Analog pin 0 needs to read the voltage drop across the Phototransistor so connect the A0 pin to the Phototransistor's collector pin.

Step 2: Code

Picture of Code
Graph.jpg

The Arduino Code takes 100 readings from the IR Phototransistor (reading taken aprox every 100uS) and using this, determines whether this signal contains the set frequency.

The code Flash_det is the signal detecting code which will detect a pulsing IR signal of about 200Hz (which can be produced with the flashing_ir code).

The frequency at which the Flash_det will detect at is set by changing the distance between two pulses (in the Flash_det code this is 48)

if(t>t2){

Val=t-t2-48; // change here

}//end if

else{

Val=t2-t-48; // and here

}//end else

If you wish to change the IR frequency that the Arduino will detect un-comment the printing out code and use it to determine the average distance between pulses (see graph). If you change the frequency too much you will also have to change the sampling rate - set by - delayMicroseconds(1);

The "Signal" function is where the detecting occurs, this will return the lowest value of the array (the signal strength of the IR source) which will be positive or negative depending on whether or not the set frequency was detected - negative if signal is detected.

Flash_det will finally print out the returned value.

-Note the Flash_det code could be modified to detect the frequency of the most prominent IR source as well as it's strength.

craftclarity6 months ago

This looks like a good way to pull a signal out of background IR noise...

MrSirLRD (author)  craftclarity6 months ago

It can still detect the signal with some low frequency background noise (or low level high frequency) but all it will tell you about the signal, when detected, is its strength