# Switching on and off a LED light if a AC is passing through a wire or not

This is the basic setup of what I'm going to do. Have a wire plugged into the mains that is then connected to a ON/OFF flip switch then goes on to the rest of my project. Want I want to do is to add an internal DC circuit supplied by a 9V battery that when detects that the switch is closed i.e. their is mains power going through the wire, a green LED will light and when there is no power, there's a red LED.

What should I do to achieve this? (I was thinking of using some sort of transistor) A circuit diagram would be great as well.

Thanks,

• A hall effect switch is what you want. Mar 25 '16 at 19:13
• @TheTinkerMan: You need to be a bit more specific. Do you want to detect current or voltage? For example, if there is nothing connected at the other end of this wire do you want the light to turn on? Alternatively do you want to sense that current is flowing to a load? If so, what is the threshold you wish to detect. Mar 25 '16 at 19:21
• en.wikipedia.org/wiki/Current_sensor
– user65586
Mar 25 '16 at 19:21

If you just want to detect mains on / off then a neon-LDR optocoupler provides a safe way to do it. I offer this as an incomplete answer as I have not tested it.

simulate this circuit – Schematic created using CircuitLab

Neons are relatively low-power and a 1/4 W 220 kΩ resistor is all that's required to light it from 230 V mains. An LDR (light dependent resistor) is used on the low-voltage side. In the schematic above I have added a 1 uF capacitor to maintain the 'mains present' signal during the zero-cross.

Neon optocouplers were used by Fender guitar amplifier vibrato circuits and are still available. A web search for 'neon optocoupler' shows up some more recent implementations for modern micros for 'mains presence' rather than the usual zero-cross applications.

Neon optocoupler for Fender vibrato. Note use of opaque heatshrink to prevent ingress of stray light. The neon appears to be on the left with bulb point visible pointing to the LDR on right.

I suggest that this idea is worth consideration. The neon optocoupler can be home-made using a regular neon, an LDR and black heatshrink.

• Great Thx that is exactly what I need!
– user104527
Mar 25 '16 at 21:48
• Thanks for accepting this answer. Do keep the mains wiring completely separate from your low voltage wiring. Use the neon-LDR as an optical bridge between the two systems. Mar 25 '16 at 22:30

Have you thought about just using a neon indicator, or maybe a switch which incorporates one, like this.

A lot easier and cheaper than a PP9 as well.