Infrared LED and KY-005 transmitter

A 940 nm infrared LED, bare or on the KY-005 board, that sends IRremote codes to another board's receiver.

Aliases: IR LED, infrared LED, IR emitter, IR transmitter, KY-005, TSAL6200, 940 nm.

Pins

Part Pin What it does
Infrared LED A The anode, the longer leg. Through a resistor to the board's pin.
Infrared LED C The cathode, to ground.
KY-005 S The anode. The current comes from this pin: there is no driver on the board.
KY-005 VCC The middle pin. It goes to the cathode through an empty resistor pad, so on most boards it is not connected.
KY-005 GND The cathode, marked -.
Both BEAM The light, as a receiver sees it. Leave it unwired and the light crosses the canvas.

Wiring one up

The bare LED needs a series resistor like any LED. Its drop is lower than a red LED's, about 1.2 V at 20 mA, so 220 ohm on a 5 V pin passes about 15 mA. A remote's LED is often run harder, through 47 or 68 ohm, since it only flashes.

The KY-005 has no resistor on most boards. Joy-IT's sheet asks for 220 ohm at 5 V (120 ohm at 3.3 V) soldered on its pad, and the middle pin then used as ground; set resistor to that value if yours has one. With the pad empty and S straight on a pin, only the pin limits the current, as on the bench.

IRremote sends on pin 3 unless the sketch says otherwise:

#include <IRremote.hpp>
void setup() { IrSender.begin(3); }
void loop() {
  IrSender.sendNEC(0x00, 0x45, 0);
  delay(1000);
}

Where the light goes

Every part points up in its own drawing. Rotate it to turn it, and set aim (degrees, clockwise) for anything between. Hover over the LED to see its beam: angle degrees either side, range canvas units long.

A receiver sees the LED when:

  • its lens is inside the LED's beam and within range;
  • the LED is within 45 degrees of where the receiver's lens faces (a VS1838B is half as sensitive by then);
  • no other part lies on the straight line between them. A breadboard lies flat and blocks nothing.

The canvas is to scale, 20 units to the tenth of an inch, so the default range of 40000 is about 5 m, what a 20 mA LED reaches indoors. Turn an LED or move a part while the circuit runs and the light goes where it now points, without a restart. Any number of boards can share one canvas; a receiver two LEDs reach at once gets both, garbled, as it would.

Wire BEAM straight to a receiver's IR pin instead and that receiver gets this LED's light and nothing else, whichever way the parts face.

While it runs

The dome glows violet while current flows, the way a phone camera shows an IR LED. An eye sees nothing.

What the model gets right

The carrier. A VS1838B answers only light flashing near 38 kHz. A steady LED, an LED blinked with digitalWrite(), or one flashed at 10 or 56 kHz is light, and lights the dome, but nothing arrives. IRremote's IrSender and TinyIRSender make the carrier on the pin as they do on a real board, and so does tone(pin, 38000).

The decoder's tolerances. A burst arrives a few carrier cycles late and ends a little late, as from a real receiver, so the marks a decoder measures are short by about 60 microseconds.

Current and burnout. The diode is the same Shockley model as led, with the TSAL6200's 100 mA rating. Held well over that for long enough, it burns out.

What it does not model

The light's strength: in range and in the beam is seen, out of either is not. Sunlight and lamps, which a real receiver mostly ignores anyway. The receiver's automatic gain control, which goes deaf to a carrier held for many milliseconds. Light that bounces off a wall to reach a receiver round a corner.

Common mistakes

No resistor on a bare LED. A board pin straight into it is about 120 mA, past the pin's own limit.

The receiver wired to the LED's board and facing the same way. A player's own receiver must face where the shots come from, not where its LED points.

Driving the LED with digitalWrite(HIGH). The LED lights, and a receiver sees nothing. Send with IRremote, or with tone(pin, 38000).

See it in action

Laser tag: two Nanos gives each player a trigger, an IR LED and a VS1838B, and counts the hits. Open it at /templates.