IR CODE TRANSMITTER HELP

I'm trying to set up an IR code transmitter to make a custom controller with an Arduino Uno.
I'm using an IR transmitter I got from Sparkfun: Infrared Emitters and Detectors - SEN-00241 - SparkFun Electronics

and I'm using the code below with the IR led connected to PWM pin 3 .

Questions: Will the Lite-ON IR send codes?
Do I connect the anode to pin 3 ?
Do I need a resistor?
Thanks

/*

  • IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
  • An IR LED must be connected to Arduino PWM pin 3.
  • Version 0.1 July, 2009
  • Copyright 2009 Ken Shirriff
  • http://arcfn.com
    */

#include <IRremote.h>

IRsend irsend;

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

void loop() {
if (Serial.read() != -1) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(40);
}
}
}

The emitter should be able to send IR codes.
The anode goes to pin 3 through a resistor to ground.
You need a resistor, The data sheet says the max continuous forward current is 50mA and a forward voltage of 1.6v
With a 5V supply the resistor would be r = (5-1.6)/0.050 = 68 Ohms. You will be pulsing it so the current can be increased to give better range. Consult the datasheet for the pulsed current spec.

groundfungus:
The emitter should be able to send IR codes.
The anode goes to pin 3 through a resistor to ground.
You need a resistor, The data sheet says the max continuous forward current is 50mA and a forward voltage of 1.6v
With a 5V supply the resistor would be r = (5-1.6)/0.050 = 68 Ohms. You will be pulsing it so the current can be increased to give better range. Consult the datasheet for the pulsed current spec.

thank you ! now this makes sense/ i looked at the datasheet now the math makes sense

The maximum peak current you should allow the arduino to supply is 40mA otherwise you risk damage to the arduino.

I take that back. I don't get the total concept.
Using
r = (5-1.6)/.05

5 is my supply . If the forward voltage is 1.6 why do we calculate?

r = 3.4/.05 which of course is 68 ohms.
rather than
r = 1.6/.05
thanks for helping this noob :slight_smile:

Because ohms law only works for resistors not LEDs.
LEDs are non linear devices, that is the current through them is not directly proportional to the voltage across them.
Therefor the only component you can apply ohms law to is the resistor.
As this is a series circuit the current through the LED will be the same as the current through the LED but you can only do the calculation on the resistor.

Grumpy_Mike:
Because ohms law only works for resistors not LEDs.
LEDs are non linear devices, that is the current through them is not directly proportional to the voltage across them.
Therefor the only component you can apply ohms law to is the resistor.
As this is a series circuit the current through the LED will be the same as the current through the LED but you can only do the calculation on the resistor.

I understand it is a series circuit. but why use 3.4vdc instead of 1.6vdc when my maximum forward voltage is 1.6vdc per specs of the ir led?

thank you so much for the description. i really appreciate the dialog

but why use 3.4vdc instead of 1.6vdc when my maximum forward voltage is 1.6vdc per specs of the ir led?

Because 1.6V is the voltage across the LED when it is on. For all intents and purposes that LED will have a voltage across it of 1.6V irrespective of how much current is flowing through it . So with 1mA flowing it will have 1.6V across it and with 50mA flowing through it, it will have 1.6V across it ( to a first approximation ) so that will not allow you to calculate anything.

BUT that same current is flowing through the resistor as well. So if the supply is 5V and 1.6V is across the LED, the rest of the voltage 5-1.6 = 3.4V must be across the resistor.
This means that the only thing limiting the current through the LED is the resistor. If you know the voltage across the resistor (as you do ) and the current you want to flow through the resistor ( which you do ) you can use ohms law to calculate what value that resistor has to be in order to satisfy the voltage across it ( forced by the LED ) and the current through ( dictated by your design )

Grumpy_Mike:

voltage 5-1.6 = 3.4V must be across the resistor.

that is epic (epico Italiano) thank you so much. I get it!

As Grumpy_Mike pointed out, and as I should have :blush:, the max current that an output will source or sink is 40mA. Safe practice will limit the current to around 20nA. If you want to drive the emitter with more than 20mA you will need a transistor to drive it.

Safe practice will limit the current to around 20nA.

Typo.
I think this should be 20mA.