9v battery to parallel 3v LEDs - burnout
What you have suffered from is what I term (I don't know if it's the real name for it) a cascade failure.  From your description your circuit is like this:







simulate this circuit &ndash; Schematic created using CircuitLab

You have sized your resistor assuming a total of 40mA through a pair of 20mA LEDs. You have also assumed a forward voltage of precisely 3.4V.

If both your LEDs were absolutely exactly 3.4V forward voltage, then you would have a chance of that working, since the current would split evenly between them. However, that will most probably not be the case. Imagine what would happen in that circuit if one LED had just a 0.1V difference in the forward voltage drop? How much current would flow through each one?

Well, most of your 40mA would go through the one with the lower forward voltage.  That would get far more than the 20mA limit it's designed for, and the other one would get next to nothing.  Yes, they may both light up, but one would be much brighter, at least for a moment, before it burned out.

Now, LEDs normally initially burn out in a dead short.  But that short soon overheats and fuses, so becomes an open circuit. So it's like not having that LED there at all.  So now all your 40mA is getting pumped through the second LED.  That's way too much for it to handle, so it then blows as well.

A cascade: one blowing causes the next to blow. If you had lots of LEDs in parallel like this and could slow down time (maybe with a very high speed camera) you'd see a distinct sequence of them blowing one by one in the order of their forward voltages (at least for the first few - as the currents got too high they'd just all go at once).

So what do you do? Simple - you treat each individual LED as a separate entity - calculate a resistor for each by itself.  For this it'd simply be double the resistance, but twice over:







simulate this circuit

So now each branch of the circuit gets its own share of the current, and each branch decides for itself what current it needs - ~20mA each in this case.  If one LED should blow the other branch is still, as an individual circuit, getting just the 20mA it needs.

To better illustrate what happens, I have drawn a pretty graph of LED current (note - this isn't a real LED diode graph, just some numbers I made up for illustrative purposes. A real LED graph would have much sharper curves, but it serves to demonstrate my point):



When you have a single resistor limiting to 40mA you're limiting the yellow line (I(tot)). At the point that's at 40mA, ~3.3V, the two LED currents I1 and I2 are very imbalanced - you can see one gets ~18mA, and the other ~24mA. The one with 24mA then blows.  Now there's no blue and red lines, only the yellow line.  I1 becomes 0, and I2 becomes I(tot).