I'm attempting to build an LED bed lamp that will be powered by 240V mains. The LEDs are these ones which if I use with a 12V supply and have calculated correctly will draw 0.24W each. I plan to use 5 or 6 of them in the lamp so will consume a maximum of 1.5W.

Initially I thought I'd use a transformer and bridge rectifier to get the required 12V DC but the transformer weighs a ton and is too bulky. The next option was to use a plug pack but I'm wondering is there is a better way?

I think it would be possible to power the LEDs directly from mains using only a rectifier without mains and stepping down the voltage but then it's not safe. Are there any smallish components that can both isolate the mains and supply a DC voltage?

  • \$\begingroup\$ Why don't you design your circuit for 5v and use a USB power supply?, that'd give you loads of options \$\endgroup\$
    – back_ache
    Aug 6, 2013 at 12:35
  • \$\begingroup\$ There are many small adapters 12DCV, with 1.5W max or more. I don't know where did you get that crazy idea to just put them to mains without stepping down voltage :). Anyway If you really run out of options ( which is very unlikely ) you could also find components like a small transformer and make your own adapter ( plug pack ). \$\endgroup\$ Aug 6, 2013 at 12:41
  • \$\begingroup\$ @back_ache points out a good reason to use USB for 5v but its not always possible. I power my outdoor LED's using a computer power supply- as its ready made, cheap and easy to chop up for my own needs + all the other benefits of circuit protection. Why don't you just gut the plug pack and use it in your circuit? They only cost a few bucks and everything is already made to spec. \$\endgroup\$
    – Piotr Kula
    Aug 6, 2013 at 12:42
  • 2
    \$\begingroup\$ You say you're wondering whether there's a better way than a plug pack. What's wrong with a plug pack, and in which way do you want a solution to be better? \$\endgroup\$
    – us2012
    Aug 6, 2013 at 13:26
  • 2
    \$\begingroup\$ Commercial products usually use plug packs for pretty much exactly this reason: it simplifies the design. They're also the sort of thing that people often have spare, if you worry about cost. It might be good to post a design of how you're wiring them up: if it's all in parallel, 5V is more suitable than 12V. \$\endgroup\$
    – pjc50
    Aug 6, 2013 at 16:33

1 Answer 1


You could use a directly coupled power supply if the unit is completely sealed. Any part of a directly coupled supply and the circuit using its power could be floating at line voltages, so this is not something you want to do for general purpose. As long as everything is sealed in the same unit that just has a line cord coming out, then these types of supplies can be appropriate.

A very simple circuit for driving two LEDs from 240 Vac 50 Hz line power is:

The capacitor will allow about 7.6 mA RMS to flow thru the two LEDs. Each LED protects the other from backwards voltage, and they light on opposite polarity half-cycles of the power line. Not only does the cap need to be rated for the indicated voltage, but it must also be rated for power line use.

This circuit is very quick and dirty in that it doesn't protect the LEDs from power line spikes. The LEDs will limit the voltage, so a power line spike will cause a burst of current thru the LEDs. If that happens too often, it will eventually degrade their lifetime. However, these LEDs are rated for 30 mA continuous and this circuit runs them at 8 mA continuous during normal operation. That will still be plenty bright at night. There is a lot of current headroom, and a occasional higher current spike of short duration really won't hurt them much. LEDs are also cheap and available, and the simplicity of this circuit makes it easy to just try it.

Again, everything needs to be sealed so that it is not possible to touch any conductive parts during normal operation.

The main advantages of such a direct coupled power supply is that it is simple and very efficient. A ideal capacitor doesn't dissipate any power. Just about all the power drawn from the line is used to run the LEDs.

Calculating capacitor value:

One way to calculate the current in this circuit is by dividing the voltage accross the capacitor by its impedance magnitude. The impedance magnitude is:

R = 1 / (2 π F C)

When F is in units of Hz, C in Farads, then R is in Ohms. In this case the capacitor impedance magnitude, assuming 50 Hz, is 32 kΩ. Figure the LEDs drop about 2 V, so 238 V is put accross the capacitor. 238 V / 32 kΩ = 7.4 mA.

It should be obvious how to work this process backwards to find the capacitance that causes a particular current.

  • \$\begingroup\$ +1. Could you include in your answer how to calculate the value of the capacitor based on the desired current? \$\endgroup\$
    – m.Alin
    Aug 6, 2013 at 12:58
  • 1
    \$\begingroup\$ @m.alin: See addition to answer. \$\endgroup\$ Aug 6, 2013 at 13:42
  • 2
    \$\begingroup\$ @nalp: Because it is only useful for very limited power and that power must be used completely inside a insulated enclosure. That works fine for a nightlight, but is no good for most ordinary electronic devices. \$\endgroup\$ Jun 14, 2014 at 15:48
  • 1
    \$\begingroup\$ I was answering a question which is effectively a dupe of this one, and it now occurs to me that your circuit lacks any inrush current protection. \$\endgroup\$ Sep 8, 2016 at 9:20
  • 2
    \$\begingroup\$ @Dmitry: True. Depending on how cheap a product this is for, you may want to put a resistor in series with the capacitor to limit inrush. LEDs can take high current pulses for a short time, but with no resistor that pulse can be very high, depending on where in the power cycle the unit is plugged in. \$\endgroup\$ Sep 8, 2016 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.