The center-mounted ceiling fixture found in most homes is a lighting fixture whose best use is perhaps to provide enough light to install other lights. You are virtually guaranteed to cast a shadow on whatever task you undertake, or have the light source in your field of vision, or in some cases, both. That's the case in my small apartment where the single futon that I use for reading and watching television sits against the wall, facing in. During the day, the window behind it lets plenty of sunlight in, but at night, the only light source is that ubiquitous ceiling fixture which, by virtue of being behind the book I'm reading (rather than behind me), doesn't do much to differentiate the type from the paper.
Of course the solution is to put a lamp beside the futon. But this isn't that kind of apartment. A lamp would take up precious floor space, and I'm using the floor for other things like standing and walking. I do have wall space though.
In fact, the ideal lamp for my situation would not take up any space, so that one isn't even aware of it if when off. It should be energy efficient, but not an ugly, toxic fluorescent lamp. A string of LEDs perched on the window frame would be just about right.
There are two lighting goals for this project. The first is to provide back fill light for reading a book. Most of the light in the room would still come from the ceiling fixture, but the LEDS will bounce extra light on the ceiling behind the reader and illuminate the page. The second goal is to have house lights for watching TV and movies. Lights that can be controlled by remote, so that after watching a movie in the dark, I don't have to stumble across the room to turn on the lights. The LEDs alone achieve the first goal. The second needs some computer automation.

The easiest way to control the LEDs and provide a nice dimming function to ease transitions in and out of black is to do pulse width modulation (PWM) which is electronic-speak for turning something on and off real fast. You could do this with just a parallel port on a computer, but it makes more sense to have a programmable controller like the one on an Arduino handle a task like that.
To construct the system, I bought 20 white LED modules from SparkFun, and strung them together in two channels of 10 modules each. The mounting brackets they provide (I broke off the screw attachment and just used the double sided tape) have enough room to thread the jumper cable for the second channel through the brackets for the first. With this method, alternating modules are on channels in an odd/even configuration. This is helpful in the low end of the dimming range where the ability to have the different channels at separate levels gives the appearance of smoother dimming.
The Arduino is very simple to use. It has a Java based IDE so that you can instantly upload your programs to the controller and test them out. I wrote a program that receives input over the USB connection and sets PWM values appropriate for the desired light level. Setting the values linearly didn't produce a fade that felt linear, so I applied a simple exponential function to adjust the output to appear more linear. I used different functions for each channel so that in the lower part of the fade, the channels have values with different luminosity to smooth the lower end, but as they increase in value, they approach 1 and the output values are not much different in luminosity.
- int(255*pow(x/255.0, 2.0))
- int(255*pow(x/255.0, 1.6))
The next component is the software that controls the system. It listens for IR events from an IguanaWorks USB IR tranceiver via LIRC and fades the lights appropriately. It responds to direct on/off commands, but it also watches for commands sent to other systems to infer what is going on in the room. For instance, if it sees the TV turn on, it fades the lights up, then slowly to half. After seeing further IR activity, it fades the lights out on the assumption that everyone has found their seat. When the TV turns off, the lights come back up.
I could hook up a physical button or switch to the Arduino to control the lights as well, but since my remote is programmable, why add more clutter? I have a Harmony 880 universal remote, which is activity based. To use it, one begins by pressing a button for an activity such as "Watch a DVD" or "Watch TV". I added a new activity, which may be unusual for a remote control: "Read a book".
