I’ve recently updated my lamp with a transistor so I can adjust the brightness of the lamp with a light sensor.
What I’ve done is run the power from the wall adapter through a transistor connected to the arduino, this way I can use pwm to adjust the brightness of the lamp because it’s got led bulbs. The pwm simply turns the LEDs off and on very quickly in such a way that if I want it to be at 50% I would the keep the led off for half the time and on for half the time and then switch very often and quickly so you can’t see the time when it’s off.
Now the lamp is mostly “on” all the day, but there is a cutoff point in the code so that the lamp is off if the brightness is too high, then when it starts getting dark the lamp compensates by getting brighter until it reaches the second cutoff point where the lamp is continuously at max brightness.
I can still turn the lamp off and on with the web interface or email, so when the evening comes I can turn it off. There is also a push button on the breadboard to cycle through the different modes, off-auto-on.
Next step is to be able to adjust the brightness through the web interface. Or instead, use rdf to publish data from the sensor and use owl to reason on the brightness, together with data about the time of day and if it is likely that I’m in the room.