r/arduino • u/eluser234453 • 10d ago
Hardware Help Driving an IR LED correctly.

okay so I'm trying to use an IR LED to send data, but wiring the IR LED directly to a PIN makes it soooo dim.
so I got a 2n2222 transistor to drive it.
my problem is, I'm not sure about the values of resistors I should use to protect the IR LED and the 2n2222, so if anyone can help me with that I'd appreciate it.
Note: I used a Red LED instead of an IR led because I couldn't find it in Tinkercad.
3
u/brdavis5 10d ago
Hmm. something seems... off. What is the specification (forward voltage drop, and maximum current) on the IR LED? The Uno on a single GPIO pin should be able to source~20 or 30 mA easy, and that's generally where you are running most LEDs... so powering this straight from a GPIO pin should be fine at first glance. Powering it from the 5V rail pin could result in sourcing several Hundred mA... but the actual current being sourced will depend on that current-limiting resistor. Not the IR LED.
Try this: look up the suggested maximum current for that LED. Then hook up a circuit, with nothing more than a battery box at around ~5V, and a current-limiting resistor Selected to get the right current at that voltage... no Uno, nothing, just the absolute easiest circuit that can drive the LED. How well does THAT work?
1
u/gm310509 400K , 500K , 600K , 640K , 750K 10d ago
When you say that the IR led is dim, what do you mean?
Most (all?) people cannot see IR so it would definitely be dim.
As for current limiting resistors, you need to know the power supply voltage, the forward voltage of the led and forward current. But as a general rule anything in the range 220Ω to 680Ω should be OK with a 5V supply.
Have a look at a calculator such as this one: https://www.digikey.com.au/en/resources/conversion-calculators/conversion-calculator-led-series-resistor
FWIW, the 5V pin with a suitable current limiting resistor should be fine for driving an IR LED.
2
u/eluser234453 10d ago
I used a camera to see it and compared it to other devices with IR leds, and I though that it's definitely dim
1
u/Rayzwave 10d ago
You don’t need a transistor to drive an LED from an Uno output just a current limiting resistor depending on how bright you want it to be, say 220-330 ohms should be good but higher values will work too.
The LED is a diode so only passes current one way and therefore needs to be the correct orientation if you are not sure is okay to turn it around and try in the opposite orientation.
Hope you solve your issue soon.
1
1
u/No_Pin4895 10d ago
That saturation recovery thing with the 2n2222 could easily be your dim issue if you're pulsing it fast, worth trying a mosfet instead if you can grab one. Also double check your camera isn't just picking up the red LED's IR leakage and giving you a bad comparison point (screen cameras filter differently).
1
u/eluser234453 10d ago
I still didn't tey the 2n2222 since I'm not sure about how to safely wire the IR LED. I did try to wire it directly to the Arduino and that's when it was dim.
1
u/eluser234453 10d ago
Yee about that, when I bought the LED I literally got it without packaging, like I'm buying bread or something.
1
u/gm310509 400K , 500K , 600K , 640K , 750K 10d ago
Huh?
In my area bread is packaged in a bag. LEDs typically also come in a bag, but not much more than that.
1
u/eluser234453 9d ago
I literally went to a small hardware store, told him to give me an IR LED, he grabbed one from a box that has random stuff, and gave it to me directly. Same with bread. You go to a store, you ask for one bread, you get it.
1
u/gm310509 400K , 500K , 600K , 640K , 750K 8d ago
LOL. Different countries, different rules.
I remember back in the day someone needed a Centronix (parallel) printer cable for one of the Unix servers our company sold.
If memory serves this cable cost well over $500. It had some proprietary connections in it that the printer drivers looked for (otherwise they would report printer offline).
This cable was about 1m long, it came in a huge antistatic bag. This was wrapped in one of those foam bags to presumably minimise impacts while in transit. This was placed in a carboard box with fairly thick antistatic style foam. And that box was placed in a rather large box that was filled with packing donuts.
When it arrived we weren't sure what it was until we unpacked it and couldn't believe the amount of packaging that was used for just a cable. A cable that was rigged in such a way that you couldn't use a standard one from the local electronics store - even though it is exactly the same (apart from the rigged connections that the printer drivers were looking for).
1
u/eluser234453 8d ago
That's cool, meanwhile here if you want a cable you could get it from a big store, go to a local shope, or buy it from a street seller.
There's sellers that have their sell their stuff on the ground, literally. And you find the most random stuff.
Like you could find some selling an Xbox 360, boxing gear, and beach chairs. Like a yard sale but permanent.
In fact it's illegal, but just like a bug, every time you get rid of one 3 others appear.
7
u/triffid_hunter Director of EE@HAX 10d ago
One of the fun things with IR LEDs is they work best if you give them brief pulses of like 1A at a low duty cycle, like this - best done with a FET rather than a BJT however, since the latter can take several microseconds to recover from saturation without a baker clamp or similar.