This project uses a low-cost mains-socket remote controller and its associated 13A plug/socket. The (battery powered) handset is hacked to be controlled by an electronic circuit and the 230V mains socket is never touched - hence a safe way of using electronics to control a mains-powered device.
I chose to use a PIC microcontroller to monitor a light-dependent-resistor. When the light level is bright, the mains socket is switched on, and vice-versa.
(The LDR could monitor the screen of a mobile phone to produce a mains socket controlled via the mobile phone system - see the last step in this Instructable.)
The original system controlled four mains sockets and could also act as a dimmer. All of these functions could be retained, I only wanted one channel, although the hack is ready to control three mains sockets if I ever need more in the future.
Step 1: Inspect the remote controller
Open up the remote controller and extract the circuit board. Mine had 12 buttons. Perhaps the hardest part of the project was to see how they were connected and draw out a circuit.