This is the basic circuit that we will use for this project. Here is how it works.
Power for the lamp is provided by a 12 volt DC power supply. The control circuit uses a LM7805 voltage regulator to keep the voltage in this section at a constant 5 volts. A 5k potentiometer (variable resistor) and a 6.8k fixed resistor control the voltage of a 330 microfarad storage capacitor. The potentiometer is also connected to the gate of an IRF510 MOSFET. The voltage at the Gate pin controls the output of the MOSFET and sets the brightness of the LED array. So by adjusting the potentiometer, you can change the voltage of the MOSFET gate pin and change the brightness of the LEDs. This acts as a basic dimmer for the lamp.
The automatic dimming function is activated by opening the switch between the potentiometer and the capacitor. The capacitor is initially at the same voltage as the output of the potentiometer. However, when the switch opened, the capacitor slowly drains through the 10 Mohm resistor. This causes the voltage at the Gate of the MOSFET to drop and the LED array slowly dims over a set time period.
The timing of the automatic dimming is determined by the values of the capacitor and resistor. With the components shown in the schematic, the lamp will be on at full brightness for about six minutes. Then it will gradually dim over the next twenty three minutes. You can also use the potentiometer to set where in the cycle the dimming begins. By using different values, you can change how long it takes the lights to dim. To determine how long the lamp will be on a full brightness, and how long it will take to dim, you can use the following formulas:
Time (full brightness) = R x C x 0.00198 (minutes)
Time (dimming) = R x C x 0.00702 (minutes)