Tuesday, November 24, 2009

LED Sensor Matrix

Concept: Create an LED matrix that uses LEDs for light generation and touch sensing (light sensing actually). This is not a new concept. It is specifically inspired by this tool,which I recently found online.

Mechanisms: LEDs can be used as photodiodes. In other words, they can be used to sense as well as create light. Therefore, it is possible to create an LED-based device that can sense touch indirectly via changes in light (as shown in the example above). It is important to note that LEDs are not as sensitive as photodiodes, and are also less responsive. The sensitivity of LEDs to light varies by the LED color – red is the most sensitive one, blue is the least sensitive one.

The best code sample that I was able to find on this topic was from one of Mike Cook’s Arduino tutorials. Here is a link to this article. The trick to using an LED like a photodiode is to reverse the flow of electricity through the LED. The LED does not allow electricity to flow through it in this direction. That said, it is able to store some of the energy from this current. Then when this current is shut off the energy that was conserved is released into the circuit. The voltage that an LED can store is impacted by the amount of light that hits it.

Earlier today I tested three LEDs as light sensors. I tried using several code samples that I found on the web. However, the only one that worked for me is the one from Mike Cook that I mentioned above. Here is a brief overview of how the circuit and code works, check out Mike’s site for the code itself:

Attach the anode pin of your LEDs to digital pins on your Arduino, attach cathode pin of your LEDs to the analog pins on your Arduino (which are also digital pins 14 through 19). Set the anode pin mode to input and the cathode pin mode to output. Then set the anode pin to low and the cathode pin to high, in order to charge up the LED. Next, change the cathode pin mode to input and take an analog reading, this will be our baseline. After 20 – 40 milliseconds take a second reading, which will give us our final values. Last, switch the cathode mode back to output and set it to low.

Here are some important things to consider when working on a prototype for this device (collected from my readings around the web on this topic):
  • Small LEDs are better because they can hold less electricity and discharge faster
  • Clear LEDs work better because the light is not filtered through colored plastic
  • LEDs can only sense lights from spectrums that have shorter wavelengths

No comments: