I needed timed control over a high powered led, so in my typical overkill fashion instead of just using a simple timer switch, I decided to use an arduino. The overall system consists of 3 parts. A box with the arduino and LED driver, a lightswitch, and an LED mounted on an outrageously large heatsink.
The sketch checks if the switch is on, and while it is, keeps the light on for an hour. After that hour, if the switch hasn’t been switched off (that starts the process over) it dims the light for 5 seconds, then shuts it off. I gave it a 5 second buffer so if one were still in the room they would have time to get back to the switch before the room plunged into darkness.
The one major quirk was that the LED driver I was using needs the opposite of what you would think to turn the led on and off. 5 volts to turn the led off, and 0 volts for fully on. If you look at the code, since I figured that would not be the case for most lights, I added a variable you can change to either have 5 volts be on or off for the led/light controller.
The other major nuisance was that the LED got really hot, really fast. I didn’t have much time, so I just threw the smallest heatsink I had that could handle the heat on the led.