Report by Guy Lee, last update 4/30/06

In the project LED Touch Sensing by Jeff Han, I saw a magic happen on a LED matrix. That LED matrix not only lighted but also sensedthe touch of fingers. At first, I thought there should be some secret behind and the LED matrix he used must be a special one. After discussing and simple trial with Tom Igoe, I found that any LED could be used as photdiode! Actually, the LED, as its name (Light Emitting Diode) implies, is electrically a diode and can be used as a detection device similar to a photodiode. But there are some restrictions:

Rule

  1. LEDs will not respond as rapidly to optical rise and fall times and PN or PIN photodiodes.
  2. LEDs will only detect light of wavelength shorter than the wavelength of light that the LED would emit if it was put in a circuit that forward biased the LED.
  3. To use the LED as an optical detector, do not forward bias the LED into quadrant # 1 of the current-voltage (I-V). (Quadrant 1 is when the operating voltage and current are both positive.) Allow the LED to operate in the solar cell mode, quadrant #4 (operating voltage is positive, current is negative), or in the photodiode mode quadrant #3 (operating voltage is positive, current is negative - ? ).

Related links

1. Using LED as photodiode
2. Introduction of diode
3. Introduction of diode (Chinese Big5)
4. Introduction of photodiode
5. Mitsubishi Electric Research Lab - Sensing and Communication Using Bi-Directional LEDs

I am also working on touch panel simultaneously as an input device for my project daPass. However, I prefer to use LED which can be both input and output device for my project if I can conquer hopefully.

Below is the test I did:

[test 1]

I used porta.0 for a LED analog-in and portb.7 for another LED output.

Check video here: video1 (800k, avi), video2 (500k, avi), video3 (serial data display, 500k, avi).

[schematic]

The test is doing when I cover the poarta.0 LED dark enough (seria data value <= 2), tehn the LED on portb.7 will be triggered to light up. Porta.0 LED is reversed by its pins to get negative voltage. Below is my code:

[PicBasic code]

DEFINE OSC 4

TRISA = %11111111  
ADCON1 = %10000010
tx var portc.6
rx var portc.7
n9600 con 16468
adcVar var word

main

adcin 0, adcVar
serout2 tx, n9600, [DEC adcVar, 13]
if adcVar<=2 then
high portb.7
else 
low portb.7
endif
pause 100

goto main

[test 2]

In this step, I used 2x2 LED matrix as photodiodes matrix with row-column-scanning. But it didnt work very well. The Leds didn't work separately. Only when did I cover all 4 LEDs that serial numbers started declining from 3.

In video1(200k, mpg), it shows how the relationship is between LED-matrix and portb.7 LED. Portb.7 LED lights up when I use coverlet on LED matrix. Video2(250k, mpg) shows that how serial changes accomanpying with covering the LEDs.

Here is my schematic:

[PicBasic code]


DEFINE OSC 4

TRISA = %11111111    
TrisB = %00000000
TRISC = %10000000
TRISD = %00000000
ADCON1 = %10000010

rows var byte
cols var byte
bArray var portb
dArray var portd
tx var portc.6
rx var portc.7
n9600 con 16468
adcVar VAR byte

main

'LEDs are sensing   

for cols = 0 to 1
bArray.0[cols] = 1
portd=%11111111
 for rows = 0 to 1
  dArray.0[rows] = 0
   pause 10      
   adcin rows, adcVar[rows]
   serout2 tx, n9600, ["adcVar[",DEC cols,44,DEC rows,"]= ",DEC adcVar[rows],10,13] 
   if adcVar <=2 then
    high portb.7  
    pause 100
    low portb.7      
   endif
  dArray.0[rows] = 1
 next
'bArray.0[cols] = 0
next

goto main

Questions

  1. I got numbers of range only 0 - 3, much less beautiful than what Tom Igoe had (which was around 20 - 300). Did I miss or mistake anything? I also tried claen-lens green LEDs but still got the same result.
  2. When I touch the power pin of the green LED, the data runs back and forth between 1-3. What does that happen?
  3. Why is there a little bit delay between sensing and lighting? Also, the LED is not sensitive so that I think there will be more trouble when I use LED dot matrix. The cover shell will interfere with the sensing substantially.