A long time ago for a product, I worked out this issue by using a current mirror. Basically, anI used a matched NPN pair wired up to sendas a mirror and sent a very small (tens of microamps) current to the LED, not enough to light it. The mirror output would swingswung enough voltage that it could be sensedread it with a GPIO. Once my diags were done I turned off the current mirror so even the phantom sense wasn’t present. IWhy did it this way as I didn’t have an ADC available andgo to so much trouble? I was very short on GPIOs and needed to resort to some tricks to reuse them.
If you have anThe ADC, you can measure the FET drain voltage with the FET ‘off’, with a bit of work. ToggleFirst, toggle the FET on'on' then off'off' to discharge the drain and trace capacitance, then quickly sense the drain voltage afterward. ItThe voltage will stay at 0 if the LED is unconnected, or drift up towards Vcc with the LED present as the LED leakage bleeds off charge.
TheThat said, the ADC sensing method poses a couple of difficulties however: ADC input range (which needs to include Vcc), and ADC input impedance loading the circuit when the driver FET is 'off'. Either one will prevent proper sensing of the FET drain charge.
What to do then? Forget the ADC. There's an easier way.
Finally: the easy way. Use a low-thresholdan nFET like a BSS138 to watch the driver drain voltage. HammerJust like with the ADC method: pulse the driver, 'on' then check the FET state immediatelyshortly afterward. If the sense FET stays off, no LED; if it turns on, LED is connected. Try it, here:
simulate this circuit – Schematic created using CircuitLab
This circuit takes advantage of the fact that there's a bit of capacitance present on the driver FET drain and the board trace. The sensing FETnFET doesn't load this, and so can detect the driver drain off-state charge with the LED present or absent.