LEDs or Light emitting Diodes to their close friends and colleagues.
The big trouble with them is they have a thermal characteristic which is the opposite of a resistor.
When a resistor warms up it’s resistance increases which means it will reduce current in a hot circuit. This is a good facility.
LED’s are the opposite as they warm up they take more current which means that there is a serious possibility ( from the LED’s perspective) that the current will increase as the temperature goes up, which will increase the heat, which will . . .
Phut.
So how do we stop this?
Well we try to limit the current that can flow in to the LED and keep it below a sensible threshold. In short a resistor of some value…
Whcih brings us to another fact about LED’s and ohm’s law.
The fact about LED’s is that they have a voltage which can be measured across the terminals and like a zener diode or the perpetual 0.6V across a silicon diode or the 0.25V across a germanium or a shottky diode, there is a voltage that the LED runs at, pretty much irrespective of the current flowing though it, until of course it goes . . .
Phut…
And this is the hint towards the value of resistor we need.
So we have a 3.3V supply and a red led ( 2.5 volts roughly)
3.3 Volts - 2.5 Volts = 0.8 Volts
An LED data sheet.
So how much current, or to put it another way how bright is the LED. to be?
Well the data sheets says the LED will do 20mA continuously but it’s just being used to indicate the presence of power so it doesn’t need to burn holes in things so start at say 1mA just to see how bright it is …
V = I R
0.8V = 0.01A * R
About 80 Ohms…
So a 80 ohm resistor or similar will perform the function.
This does two things. It keeps the current going through the LED limited, which is of interest to the LED, but as you have it wired the Forward voltage of LED acts like a zener diode and clamps the voltage across it to, well in the case of this Datasheet, 2.5V which is probably a bit marginal for the MCP23017. Put the LED in series with the 80 Ohm resistor and the LED and the MCP23017 can each comfortably run at the voltage they want to, with any current flowing between them will be limited by the resistor and the V = IR solution.
Basically if dealing with LED’s there will be current limiting resistor somewhere around to limit the volt drop from the supply it’s connected to . . . . .
Just for reference the Blue Pill STM32 Board uses 3.3Volts and 510R resistors, so it looks like one can go considerably lower current . . .
Hope this helps. I just happened to be reading about laser diodes this morning and that’s where the temperature comp stuff comes from . . .
Course if you really want temperature stability, who wants to describe multi VCO temperature ovens…?