I have built a domestic wall light that uses an Arduino Uno to control a servo that creates motion in some parts of the light. However I need to "pause" the Arduino when the light is switched off. I have mains electricity (220v) coming in and a transformer which steps this down to 12v DC 350-700mA. This transformer is used to power a bunch of LEDs. The Arduino is currently powered by a 9v PP3 battery.

Can I "sense" if the transformer is on and so stop the servo? I reckon the software is trivial if I can somehow figure out the electronics. Can anyone point me in the right direction?

I don't have an electronics background but have been able to build basic circuits from the various Arduino books.

You've got one simple issue do deal with... You can't put 12V into the Arduino. You just need to drop that 12V down to 5V at the Arduino input (without affecting the other stuff that's connected to 12V).

If your "transformer" is putting-out DC, it's actually more than a transformer, and that's good, since you can't put AC (or negative voltage) into the Arduino.

I'm going to describe this in words because I although I've been working in electronics for a long time, I don't have any schematic-drawing software. I'm gonna' have to get 'round to that...)

Put a resistor (~10k would be good) between the 12V from the transformer and one of the Arduino's inputs. Then connect a diode between the same input and the Arduino's regulated 5V power supply (i.e. the "5V" pin), with the anode on the input (i.e. "point" the diode toward the 5V supply). Any regular silicon diode will work, since there is very little current through the 10k resistor.

Whenever the voltage goes above 5V (plus the ~1/2V drop across the diode), the diode "turns on" and "clamps" the voltage at 5V (plus the diode drop). The "remaining" ~7V gets dropped across the resistor.

Krodal - a optocoupler sounds interesting but I'm not sure it'll work in my light.

DVDdoug - I think I understand the circuit you've described. Let me describe it back to test my understanding.

I take the 12v +ve output from my transformer (it's a Dialight MDU-18) and feed it in to a 10k resistor. That resistor is then used as an input to my Arduino. Which input pin should I use? Sorry, I think I should be using a digital pin but I'm not sure. I've drawn this circuit and attached an image of the diagram.

I've written a few sketches (by modifying existing ones) but never detected High / Low before. I've done some research and think I may want something like this -

Put a resistor (~10k would be good) between the 12V from the transformer and one of the Arduino's inputs. Then connect a diode between the same input and the Arduino's regulated 5V power supply (i.e. the "5V" pin), with the anode on the input (i.e. "point" the diode toward the 5V supply). Any regular silicon diode will work, since there is very little current through the 10k resistor.

Whenever the voltage goes above 5V (plus the ~1/2V drop across the diode), the diode "turns on" and "clamps" the voltage at 5V (plus the diode drop). The "remaining" ~7V gets dropped across the resistor.

What definitely is missing is the connection from the 0V pin of your 12V source to Arduino GND.

Not sure if it's a good idea to sink those probably noisy 12V into the 5V ? But if your Arduino is not doing anything else, why not...

A 4.8V zener diode to GND, or a 4.7k resistor to make a voltage divider 2-1 = around 4V at the digital pin, might be more suitable.

Any digital input (except 0 and 1 for Serial) should be fine.

BTW.

Quote

I don't have any schematic-drawing software. I'm gonna' have to get 'round to that...)

Thanks pylon - that's ideally what I'd like to do. I tried powering my Uno from the transformer via the jack socket but it didn't seem to like it. The transformer was supplying 12v DC and 350-700mA but I have no idea if this is too much or too little. I didn't get any lights on the board. It still works fine so at least I didn't fry it