IR Receiver

Hi

is an ir reciever digital or analog?

Also if i were to make a simpile sketch to read it would it go like this

int senspin=3;
void setup {
 pinMode( senspin, INPUT);
 Serial.begin(9600);}
 
void loop {
  int val= analogread /** or digital read **/ (sensorpin);
  Serial.println(val);

 
  delay(100);
}

Depends on the sensor

A IR phototransistor (the one that looks like a led) could be read as either a digital or analog signal --and would of course, need a pullup resistor etc.

A 38khz sensor (3-pin, used with remote controls) is read as a digital input and requires some “decoding” when/as the signal is received.

From my recent experience
From my recent experience with analog pins on the Arduino UNO; you won’t need the pinMode() function which is used with digital pins if you are reading an analog ir photocell. If it is digital then you’d keep the pinMode(); and use digital read. There are also some libraries/code available eg: http://arduino.cc/playground/Code/InfraredReceivers
It would be helpful if you/we knew exactly what part you were using and how you planned to wire it.

Or if you are looking for one you could check the data sheet. Most suppliers have data sheets posted With more detailed information; sometimes even example wiring (though probably not for an Arduino).

Just my $0.02, hope that helps.

There are different IR

There are different IR receivers/sensors. 

This is an analog one, most common called Sharp and should work with your code:

1-Sharp-Analog-Infrared-Range-Finding-System-AERS.jpg

Another kind are the digital receivers/transceivers:

Transceiver:

bb_digital_ir_switch_50cm_1.png

its sending a signal and gives you a HIGH when it gets the signal back to the receiver. Normally you can adjust the range with a small screw...lets say 50cm. If in 50cm something blocks the beam it will get refelected back to the transceiver and trigger the HIGH signal.

Receiver:

Infrared_Receiver_Module.jpg

Those are codes to a certain frequency. Most of the time 38 or 56kHz and just looking for a IR signal which is modulated in these frequency. If it sees the IR signal it will give you a HIGH on the output.

 

Here it is.

if you just want to read the sensor val i got the code

int sensorpin = 0;                 // analog pin used to connect the sharp sensor pin 0 analog
int val = 0;
// variable to store the values from sensor(initially zero)

void
setup()
{
  Serial.begin(9600); // starts the serial monitor
}
 
void loop()
{
  val = analogRead(sensorpin); // reads the value of the sharp sensor
  Serial.println(val); // prints the value of the sensor to the serial monitor
}

by far the most thorough explanation

if you want to use the 38khz receivers. The best explanation by Robotx is here.

38khz sensor

I have the 38khz sensor that is used in remotes… i have the remote too. What do you mean by decoding?

Receiver

I have the reciever. But does it really only out put high or low? I thought it out puts numbers

Thank You

38khz sensor

I have the 38khz sensor that is used in remotes… i have the remote too. What do you mean by decoding?

Don’t make it look like your code if it isn’t.

Mukund22kar. As once Geir Anderson told you to not copy&paste code or content from other websites to LMR without adding a reference to the creators. Always make a distinction between content from you and content from other people. You should not make copyright infringements.

The code-snippet you present here may come from there.

Keep in mind that you are a very talented person. No need to adorn yourself with borrowed plumes.

Just got back from the googles

Ok, so I took the liberty of going to the googles for you. I googled “arduino IR…” at which time the autofill gave me an option called “Arduino IR Tutorial”. I clicked it.

I ended up here:

http://www.ladyada.net/learn/sensors/ir.html

How it works, how to test, how to connect to arduino, example code.

Thanks

I was spent a half an hour before looking for something like this. but didnt get this … thanks

Sorry nilsB.

i will look that not to copy paste any one’s content.

Copy&Paste whatever you want

Copy&Paste whatever you want. Make shure you give the creators a credit. All fine then.

Which one do you have? The

Which one do you have? The Sharp spits out a lot of numbers for the analog readings. The others should only give you a HIGH (1) or LOW (0). Make sure your DIGITAL sensor is connected to a DIGITAL input…or analog to analog…