Tuesday, 26 April 2011

It's stopped working!

Last night we celebrated (albeit in true nerd style, with a cup of tea and a Bourbon biscuit) after getting our "shadow harp" working properly.
It was possible to trigger 1,2,3 and even 4 different samples in sequence (one after the other) or together (by spreading my hands sideways and covering all four inputs at once). It seemed to be working exactly as designed.

This morning, keen to repeat the successes of last night, I plugged the new instrument into my PC and tried to play a simple tune. Nothing!
The LDR values didn't seem to change. I altered the sensitivity threshold but only saw activity when it was reduced down to 2 instead of 10 as it was last night. This was so sensitive that other inputs were triggering sounds even at the slightest movement near them.

I noticed that the raw input values had increased from around 220 to 252 and reduced very slightly when the end of each tube was covered.
Thinking about how the LDR works (with a variable resistance from 5Mohm down to a few hundred Kohm) it sort of made sense. During the day, natural daylight floods the room, so the "top" resistance is lower, compared to the fixed 1Mohm resistor to ground. At night, when playing the instrument under artifical light, the somewhat dimmer conditions mean the "top" resistor has a higher value - so the ratio between the top and bottom resistors is lower on each input pin. This theory is in line with the input values seen: at night, the input values are noticeably lower than during the day.

The solution? Not sure - my gut reaction is to replace the bottom resistors with linear pots, so that the instrument can be "tuned" to the ambient light conditions.
A simple set-up screen when the instrument is first switched on will allow the user to find the optimum values for the "bottom" resistor before play commences.
Perhaps something like take a reading from each pin in turn, compare to the mid-point (128) value and display it as a bar on the screen. The user then twiddles each pot in turn, until all inputs are set to about half-way. They can then press a button to start playing the instrument, knowing that hand gestures will be correctly sensed and processed as inputs for the device.

[update: I just tried replacing the 1Mohm bottom resistors with lower valued ones (about 330Kohm) and the instrument once again became sensitive enough to play. It seems that allowing the user to change the initial resistance of the bottom resistors (i.e. replace with potentiometers) could be the way to go!]