Most of it's been covered, but a few comments to tie up loose ends:
First, it's not correct that the brightness of each LED will be different in the series configuration. Basic circuit analysis here: if current through LED1 is X, current through LED2 and LED3 must be X, too. LED brightness is purely a function of current, once you exceed the LED's
Vf threshold. For it to be otherwise, current would have to be "escaping" the series string somehow.
Second, your chosen resistor value is too low, for two different reasons:
- 20 mA is the outer limit of what these LEDs can tolerate, not a minimum operating current. I'd be surprised to learn that you need more than 5 mA for your project to work reliably. Keep in mind, infrared LEDs are used in remote controls, where a battery typically lasts months or years. Hard to imagine that they're using 20 mA, even just in brief pulses, and still getting that kind of battery life. Your project works over the same distance as a TV remote, so you should be able to use drive currents in the same ballpark as a remote control.
- You've calculated based on ideal component values. A 270 ohm 5% resistor can be as low as 256.5 ohms, and a "9 V" alkaline battery starts out at more like 9.6 V when fresh. The current through the LEDs could thus be over 22 mA. I doubt you risk instant LED death at just 10% over the max limit, but why push it? Also, it's even worse with some flavors of "9 V" NiMH rechargeable, which can be well over 10 V when fresh out of the charger.
I'd put a 1K pot in series with that resistor and dial it up until your project stops working. Then measure the resistance of the pot and add the fixed resistor value to find your maximum resistor value; and then measure your battery voltage again, to find out what voltage it really is. This will give you the minimum operating current:
Imin = Vbattery / (Rpot + Rfixed).
Third, now that you know
Imin, seriously consider using a constant current source for the LED current limiter instead of a resistor. It adds a tiny bit of complication relative to a resistor, but it's much more efficient.
If you use resistors, to get full use of the battery, you have to set the resistor value to give
Imin when the battery is dead, about 5 V for an alkaline "9 V". If you calculate the resistor to work clear down to this 1.1 V difference between the battery voltage and the LED string minimum voltage, you find that the resistor has to be 55 ohms, which makes it way too small when the battery is fresh: ~100 mA with a fresh 9.6 V alkaline! So, you go the other direction, sizing the current limiting resistor for a fresh battery, giving the LED string's max current at that voltage. This is what you did above, but modified to take into account real world tolerances: R = 1.05 * (9.6 / 0.02) = 300 ohms. Now you calculate where this causes the current through the string to drop below
Imin. Say it's, 5 mA: V = 1.5 over the string minimum, or 5.4 V. You can't completely use up the battery, but you do get close, at the expense of using way more than
Imin through the greatest part of the battery's useful life. There's the inefficiency I talked about.
Now switch to a constant current source (CCS). With an alkaline 9 V battery dying at around 5 V, that means we have 1.1 V left over for the CCS, which is barely adequate. Even if we have to call the minimum supply 5.4 V like with the resistor situation above (1.5 V left for the CCS) we're still much better off because we keep on using
Imin no matter what the battery voltage is. You could even decide to put in 2x9V to get a longer run time, or switch to a wall supply and not care much about what voltage it really puts out.
Go ahead and use resistors while prototyping. But when it comes time to box the project up for the last time, place a Mouser order for a CRD of the correct value. Or, if your time is cheap, buy a bag of JFETs and measure Idss for them until you find one in the proper range. A JFET with drain and source shorted together is a pretty good CCS.