[Steven Mackaay] added a simple user interface that implements a shutoff timer for his desk lamp. His project log comes in two parts, the breadboarding and the actual implementation.
He wanted a few things out of the build. The first is an LED that would help him find the lamp in the dark. The second feature is a shutoff timer with different delay options. To get everything working he used a PIC microcontroller to drive a mechanical relay. That relay switches the mains power to the lamps. Now he uses one button to switch the lamp on and off. The other selects a shutoff timer of one, five, or thirty minutes. Power for the control circuitry is provided by the green wall wart PCB seen in the photo of the electronic guts.
This is a pretty general setup that could be applied to a lot of other mains switching applications. Just connect the logic hardware to some type of relay.