IR emitter not emitting, but multimeter says it is fine

So I bought 5 pairs of infrared emitters and receivers from eBay (here's the website: http://www.ebay.com/itm/5-pairs-Infrared-Diode-LED-IR-Emission-and-Receiver-CG-/151603405250?hash=item234c4461c2). When I was testing the emitter and receiver with the code I had just typed up, they were not working. The purpose of the code was to make sure the receiver could detect the emitter, being always on. The two were clearly in range of each other and I had made sure the connections were correct. However, the emitter was not emitting any infrared light as I checked with my phone's camera. I replaced it with a brand new one, but it still didn't emit anything. The emitter used a resistor of 330 ohms for it's 2.7 - 5.5 volts to a 5 volt source, the Arduino Uno. The other side was the Arduino Nano using a VS1838B infrared receiver.

Here is the code for the receiver:

int IR = A0;
int val = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
    val = analogRead(IR);

    if(val == 255)
    {
      Serial.println("Receiving Message"); 
      delay(5000);
    }
    else
    {
      Serial.println("NO SIGNAL");
      delay(5000);
    }
}

Here is the code for the emitter:

#define IE A0
void setup() {
  Serial.begin(9600);
  pinMode(IE, OUTPUT);
  Serial.println("Intializing...");
  delay(1000);
  Serial.println("Ready");
  delay(1000);
}

void loop() {
  analogWrite(IE, 255);
}

Is it my program that is bad, including my emitter, or is it just the emitter? I need help, since I lack knowledge of any Infrared technology, including this receiver and unsure if it is a photo-receiver or not... Also I'm starting to lose trust in eBay... and I have been trying to solve this for 4 days...

Those IR detectors are complicated devices that recognize only IR signals that are "chopped" at 38 kHz. They do not recognize steady state IR signals.

To use the detectors, you have to program the Arduino to modulate the IR emitters at 38 kHz. The emitters also have to be wired the right way around, or they will be destroyed. The same holds for the detectors.

Search the forum or google "arduino ir led 38khz" for lots of examples.

Thank you for replying, but two questions, I want to make this as compact and simplest as possible because this is part of my project for swarm robotics, but I see it would require a timer, and I'm pretty unfamiliar with that stuff, so is there a way?. Also, another question is my IR emitter isn't even emitting, and I need to work that out first, so can it be fixed, and how?

it would require a timer

Timers are built in to the Arduino (3 of them). You use them programmatically.

If your LED has ever been connected backwards, or forwards without a current limiting resistor, it may not be functional. Study the examples to make sure you know how to orient it, and use a current limiting resistor (220 ohms minimum for a 5V supply) in series with it.

Alternatively if you have a multimeter, check it on the "low ohms" or "diode check" range.

You can check the detector function (and your cell phone camera) with a TV remote -- most are modulated at 38 kHz, but there are exceptions.

Now I know what to do with the emitters and the receivers and how to connect them :slight_smile: Thanks. But another question, is the program okay with the emitters i'm using? Is the parameters in the if statement correct? Do i need to add more?

but another question, is the program okay with the emitters i'm using?

No.

Is this all in digital or analog?
I get confused whether this is a photo receiver or not, and if it even matters

The VS1838B is much more than a photo diode.
It contains all the parts for a complete remote control receiver.
Photo diode, gain stages and a detector/driver.

Only short distance (covered) sensors use constant IR light.
Remote controls use modulated IR light, so the data transmission is not influenced by ambient light.
The last two digits of the model number is the frequency in khz.

If you let the Arduino generate 38khz, and drive an IR LED with that signal, the output of the sensor will be LOW.
Data is transmitted by switching the 38khz signal on/off.
There are remote control libraries that do the heavy lifting for you.
Leo..

But how would I use the remote control library when my IR receiver and emitter don't use a remote for anything... I do know a library for this, it's just really confusing why I should use it instead of typing my own code... Sorry for being really incompetent, I have little knowledge on sensors, especially Infrared...

I got 5 pairs of IR emitters and receivers, and I was checking to see if the IR emitters were emitting, but they weren't... I checked with my multimeter and selected the diode mode and the multimeter said it was fine. Looking through my phone's camera, I couldn't see anything, not even the faintest flash. I looked to see if the connections were bad, and still nothing came up, so I checked my resistor, and I thought 330 ohms was fine for a 4.5 volt emitter and a 5 volt source. here is where I got the emitters and receivers: http://www.ebay.com/itm/5-pairs-Infrared-Diode-LED-IR-Emission-and-Receiver-CG-/151603405250?hash=item234c4461c2. I need help on this problem...

why I should use it instead of typing my own code

You are more than welcome to "type your own code", but to do so you have to understand how everything works.

So, you have some choices.

  1. Do some research into how a timer in the Arduino can be set up to generate a 38 kHz signal (while not messing up other required timer functions), then write the code.

  2. Read up on how someone else solved the problem, and use their code.

  3. Use external components, like a 555 timer IC, to generate the 38 kHz signal.

Why do you think your camera hasn't got a good IR filter? Most have these days.

Also are you sure these are just LEDs and not modulating IR sources? What is the forward
voltage with the 330ohm series resistor - if its not 1.1 to 1.5V I'd suspect its a whole
emitter circuit, not a bare LED.

If you have a iPad or a iPhone, try the camera on them.

Have you tried the pair together with an IR remote receiver sketch?
Maybe you have not identified the anode and cathode correctly.
.

Do not double post.

Whoops sorry for double posting
But I couldn't get that emitter to work
Yes, the LED is in a circuit with just the resistor and the Arduino uno backing it with 5 volts, and my iphone 6s camera should detect the IR light, but it didn't. I made sure the light sources were not interfering and did it in a pitch black room. Every connection is correct and the anode and cathode were in the right places. I'm reluctant to use the IR remote sketch because I don't have that much time before my project is due, which this is part of my project.

Again sorry for the double post, im new to the forums...

Place an ordinary red LED in the circuit, in series with the other components, as a sanity check.

+5-------A_IR_K------A_red_K------270ohms------Gnd

I am not certain, but shouldn't you use a PWM pin for analogWrite()? A0 is defined as the analog input #0 on the board. It supports digital output as well as analog input, but no analog output. Try a PWM pin instead. They have the ~ by them, and are on the digital pin side.

If as someone else said you need a particular frequency you will need to look up how to output a specific frequency on the pin. You will have to use one of the PWM pins for that for sure, though. (I don't know the code for that. Sorry)

Measure and tell us what is the forward voltage drop of the LED?