# wiring AC switch with DC led

This is a follow up to a previous question I had answered. I'd like to show the following diagram.

Here, I have laid out (crudely) a diagram that has 120v-110vAC from the wall going to a push button switch that controls an Edison bulb and has an integrated LED on the switch. The wiring diagram for the switch is as follows:

and here's what the switch looks like ideally when operated.

Can anyone recommend a power supply that will allow for me to both wire in parallel my switch taking 120v-110vAC from the wall and output to Edison bulb (per my diagram) and that also has an output of 5v or 12vDC for the LED that is integrated into my push button switch? I'm looking for something that is of an extremely small form factor. Max dimensions have to be 1/2" width :1/4" height and can be up to 3.5" long to fit inside my project space.

I had contemplated taking apart an apple USB wall block, wiring it in parallel with my switch, and then using the USB output to run power to the light. Unfortunately, I'm not sure how to best to insulate the exposed guts of the wall block or if this is even a smart/safe idea. (any thoughts on that are appreciated).

I would honestly be willing to build my own if I knew enough of what I was doing and because I only need it to power 1 LED. I feel like with such a light load I should be able to use something in an extremely small form factor. I just want to be safe. I don't want to create a fire or electrocution hazard.

## 1 Answer

You can do this with direct conversion. Simply use a rectifier, followed by a mains-rated capacitor, then connect this to your LED in series with a very large resistor. You don't need to generate 5 or 12 volts - the series resistor will limit current through the LED. Something like this:

simulate this circuit – Schematic created using CircuitLab

You could go even lighter weight and use a single resistor and capacitor but for two issues: it would flicker at 60Hz, and most LEDs aren't rated to withstand mains voltage in reverse bias.

Things to look out for:

• Remember that rectified mains is 1.41 times the RMS voltage, so spec the DC part of your circuit for 338 (169) volts, not 240 (120).
• Size R1 appropriately to the amount of current you want through the diode. In the schematic above, I've sized it to allow 2mA through for 240V mains.
• Make sure R1 can handle the power dissipation; in this case it'd be 0.67 watts, so make sure you use a power resistor.
• Mains voltages everywhere! Take care, and make sure it's well insulated.
• I'm not sure this would pass the "I just want to be safe. I don't want to create a fire or electrocution hazard."-requirement. – jippie Jun 3 '15 at 6:38
• @jippie There's no risk of either if done properly. Direct conversion is commonly use for far more demanding circuits. This is also how every wall socket indicator LED ever works. – Nick Johnson Jun 3 '15 at 6:42
• There's going to be exposed mains voltage on the back of the switch anyway. I don't see that having a few more components exposed to mains voltage is going to make much difference. The OP just needs to make sure that everything is enclosed and nothing can short to exposed metal. – DoxyLover Jun 3 '15 at 6:44
• i'm so glad to hear that this isn't too difficult. I'm pretty inexperienced though and will have to take some time to "translate" your diagram so I can understand what's going on. Do you have any suggestions on how best to insulate this? I'd like to add that this whole setup is going into a metal pipe so the last thing I want is it to ground out to the pipe body and have one of my cats electrocute themselves if they touch it. I'm assuming something more robust than shrink tubing and electric tape is necessary but that again could be my inexperience. – Panayiotis Spanos Jun 3 '15 at 6:59
• @PanayiotisSpanos They're rectifier diodes; together they form a half-bridge rectifier, turning AC from the mains into a sort of lumpy DC, which the capacitor smooths. I'd recommend getting something like ltspice out and simulating the circuit to better understand how it works. – Nick Johnson Jun 3 '15 at 8:13