IR SENSOR

deba168
Posts: 7
Joined: Tue Nov 27, 2012 3:03 pm

IR SENSOR

Postby deba168 » Tue Dec 04, 2012 1:55 pm

please give details about IR Tx/Rx.....I want to use it for glowing a led when a person go near to it....
abhimanyu
Posts: 94
Joined: Tue Oct 18, 2011 9:49 pm

Re: IR SENSOR

Postby abhimanyu » Fri Dec 28, 2012 8:35 pm

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).
Attachments
Schematic on mini BB_bb.jpg
Schematic on mini BB_bb.jpg (203.49 KiB) Viewed 2340 times

Return to “Sensors”

Who is online

Users browsing this forum: No registered users and 0 guests