Page 1 of 1

IR SENSOR

Posted: Tue Dec 04, 2012 1:55 pm
by deba168
please give details about IR Tx/Rx.....I want to use it for glowing a led when a person go near to it....

Re: IR SENSOR

Posted: Fri Dec 28, 2012 8:35 pm
by abhimanyu
The IR LED (Rx) has a black coating on it. The Tx is the usual clear or violet colored LED.
As a starting point, you may detect objects upto 6 inches apart. You will need to connect everything according to the following schematic:
[See Image attached]

Example Arduino Code:


int Alert = 2; // Connect Alert!! LED to Digital pin 2
int infraRed = A0; // Infra Red Receiver (Photo Diode) to Analog Pin A0
void setup()
{                              
  pinMode(infraRed, INPUT);
  Serial.begin(9600);
}  
 
void loop()
{
  int x = analogRead(infraRed);
  Serial.println(x);
  if(x > 1020) // Since Arduino has 10-bit ADC,
                       // the range of input from IR Rx (Photo Diode) would be between 0 - 1024.
                       // you will find that when an obstacle is detected,
                       // the value in Serial Monitor is just close to 1024 (i.e., HIGH).
                       // It works when both IR Tx and IR Rx (Photo Diode) are upto 6 inches apart.
    digitalWrite(Alert, HIGH);
  else
    digitalWrite(Alert, LOW);
}



Note that in the schematic, IR Receiver is not connected like a normal LED with cathode to Ground.
Since it is actually a transistor with 'open' base to detect light.

The Alert!! LED will not Light up until there is an obstruction in between the InfraRed Tx and Rx (placed 5 to 6 inches apart).