A single LED can be illuminated by using a 100n or 220n capacitor with a rating of 400v. These capacitors are called "X2" and are designed to be connected to the mains.
The LED will be 240v above earth if the active and neutral are swapped and this represents a shock of over 340v if anything is exposed. The power diode in the first diagram is designed to discharge the 0.22u during one half of the cycle so that the capacitor will charge during the other half-cycle and deliver energy to the LED. The 1k resistor limits the peak in-rush current when the circuit is first turned on and the mains happens to be at a peak.
Two LEDs can be driven from the same circuit as one LED will be illuminated during the first half cycle and the other LED will be driven during the second half of the cycle.
LEDs can also be connected to the mains via a power diode and current-limiting resistor. But the wattage lost (dropped) in the resistor is about 2.5 watts and a 3 watt resistor will be needed to illuminate a 70mW white LED.
This is an enormous waste of energy and a capacitor-fed supply shown above is the best solution.
When 50 to 80 white LEDs are connected in series, a resistor can be used. For 50 white LEDs, use a 4k7 2watt resistor to provide 10mA average current.
For 100 white LEDs, use a 2k2 1watt resistor to provide 10mA average current.
The circuit will not work with more than 95 LEDs as the characteristic voltage-drop across the combination will be more than the peak of the supply (340v).
DC CONNECTION
To prevent "flickering' or "strobing," the LEDs must be driven with DC. This requires a BRIDGE. (A bridge is used in this circuit however the secret to prevent flickering is the addition of the electrolytic and the circuit can be driven by a single diode in half-wave.)
The 0.22u will deliver 15mA when one LED is connected to the output. As additional LEDs are connected, the current gradually reduces to zero with 100 LEDs.
40 LEDs will be provided with:
345 - 145 = 200v = 200/345 x 15 = 8.6mA