The Mystery Clock
This device consists of five photoresistors and a superbright LED strapped to a servomotor, all inside a circular, opaque box. The photoresistors are taped to the box's inner wall and the servomotor is secured to the bottom of the box, dead center. (See below the cut for a photograph, sound samples, and source code for the Processing and Arduino programs.)
Here's how it works. A program on the Arduino instructs the servomotor to turn the LED toward each photoresistor in turn, returning to the first position at the end of the sequence. The Arduino program keeps track of a value for each photoresistor; this value is incremented proportionately with the reading from the photoresistor each time through the
loop() function. The Processing applet reads these values via serial connection and uses them to control the volume of five pitches.
The Arduino, in turn, reads a value between 0 and 128 from the Processing applet. This value corresponds to how close the current time is to half-past the hour (e.g., at 9:30 the value would be 128, at 10:00 the value would be 0, and at both 9:45 and 10:15 the value would be 64). The Arduino uses this value to determine two things: First, how fast the values in the photoresistor array should "decay," and how frequently the LED should turn on and off. The net effect is that fewer notes are played at the beginning of the hour, with a faster decay, while at half-past, notes are played more frequently and decay more slowly.