I currently have a circuit that controls the state of a relay. The relay is driven by an NMOS transistor M1, and the gate of the NMOS is driven by a microcontroller. Additionally, I have an LED indicating the state of the relay, and this LED is also controlled by an NMOS M2. The circuit looks like this: -
simulate this circuit – Schematic created using CircuitLab
The gate of both NMOS are driven by the same microcontroller pin, so they turn on and off synchronously. When D1 is HIGH, the relay is conducting and the LED is on.
I want to get rid of M2 but I still want an LED to show the state of the relay - but I don't want to drive the LED directly from the microcontroller pin. The LED should be supplied by \$V_\text{DD}\$. The NMOS device is allowed to be changed into a PMOS transistor. Would something like this work? Or is there another approach that is more reasonable.
Edit
I now realize that my suggestion will obviously not work, because M1 drives the anode of the LED to 0 volts when on, and the cathode is also connected to ground - hence no current flow.