This week I made a concept browser that intends to reduce Facebook usage by deliberately restricting the visible area of a Facebook page. To improve the visibility of that page, the user has to turn on his flashlight and point it towards a sign, while operating a mouse or trackpad at the same time. The sign has a light sensor, and a message that discourages Facebooking. The visible area surrounding the mouse-pointer will depend upon how much light is incident on the sensor.
I implemented this concept using Processing. I started with Neil's hello.light.45.py and the SerialCallResponse.pde from Processing's example library. I tweaked the Serial\SerialCallResponse.pde code to match Neil's logic. Then I combined it with an example code titled Brightness.pde in Processing's Image Processing Library. The filtered sensor value feeds into the maxdist parameter in the Brightness.pde code.
I went through the data-sheets to understand different code snippets. I was particularly stuck at how the prescalar value was set (/128). I later found out that the ADC clock was recommended to be between 50KHz and 200KHz.