LED Light Timer

Half of my family tends to fall asleep with the light on. It doesn’t feel right to leave the light on all night, so we ‘improved’ the two lamps to have a timer that turns off after twenty minutes. Here’s the basic setup. We used this IKEA LED lamp. It has a wall socket transformer that produces an output of 4 volts; a cable runs from the transformer to the lamp, with a switch in the middle. The lamp itself is a single white LED, which probably needs about 3.3 volts; I didn’t verify this. We insert the timer somewhere in the cord. It doesn’t matter whether the timer is before or after the switch, it works the same in both cases. The timer is based on a capacitor discharging through a resistor, coupled to a MOSFET transistor, and it doesn’t contain more than those three components. I explain the working of the timer in more detail below.”