<A href='http://www.user.dccnet.com/wrigter/picaxe/hexledsensor.gif ' Target=_Blank>External Web Link</a>
shows an example of LEDs used as self illuminating photo sensors.
I used garden variety high efficiency clear lens red LEDs with 1K resistors for current limiting.
The bidirectional port (out0-7) of the 18x (thanks to hippy)is used first as inputs to measure whether the light on each LED photosensors generates a time constant that is more or less than a threshold.
Then the LEDs with a longer time constant (ie lower light) are turned on for 10ms and the process repeats.
The result is that if a shadow is cast on any LED in the array, illuminated externally by moderate ambient light, it will light up.
<code><pre><font size=2 face='Courier'>
;HEX LED SENSOR/INDICATOR FOR 18X
;wilf rigter - 07/01/07
do
poke 5,8 ;serout=1
pins = %00000000 ;out0-7=0
POKE $AE,%11111111;out0-7=input
pause 10 ;set threshold
peek 6,b0 ;b0=out0-7
POKE $AE,%00000000;out0-7=output
poke 5,0 ;serout=0
pins=b0 xor $FF ;output b0
pause 10
loop
</font></pre></code>
The light to LED conversion process takes several steps:
1) The LEDs are reverse biased by setting serout=1 (poke 5,8) and out0-5=0. This charges the LED junction capacitance to 5V while the voltage on out0-5 is 0V.
2) pins out0-5 are configured as inputs
3) pause 10ms during which
4) the voltage on pins out0-5 starts to rise from 0V to 5V as the photo leakage current discharges the junction capacitance.
5) transfer input state of pin out0-5 to b0 (zero is read if the voltage on that pin has not decayed above the logic 0 threshold).
6) pins out0-5 are configured as outputs
7) set serout=0 (poke 5,0)
8) transfer b0 inverted to out0-5 to light the LEDs that were dark.
9) pause 10ms
10) repeat
The circuit was tested on a breadboard which adds significant stray capacitance to the circuit which increases the photocurrent controlled time constant.
PAUSE 10 sets the light threshold for the conversion. Larger values give higher sensitivity at the expense of noticable flicker as the conversion cycle time is increased.
A PCB with careful layout will give a shorter time constant and may allow multiplexing a matrix of 5x7 LED sensors.
More complex code can provide proportional light measurements for each LED.
Note that the out6 and out7 pins don't work for this application. They work fine as outputs and with switch inputs but I suspect that these are configured internally with a weak pullup resistor. More experiments will bear this out.
One application for this self illuminating LED sensor array is an art project I have in mind for a SHADOW CAST LED MIRROR which illuminates the silhouettes of passing people.
On the other hand I have used the bi-directional pins of an 08M to control a single LEDsensors to automatically start flashing when it gets dark.
On the gripping hand, hmmm... well I'm sure you'll think of something much more exciting.
enjoy
wilf
Edited by - wilf_nv on 09/01/2007 10:14:24
shows an example of LEDs used as self illuminating photo sensors.
I used garden variety high efficiency clear lens red LEDs with 1K resistors for current limiting.
The bidirectional port (out0-7) of the 18x (thanks to hippy)is used first as inputs to measure whether the light on each LED photosensors generates a time constant that is more or less than a threshold.
Then the LEDs with a longer time constant (ie lower light) are turned on for 10ms and the process repeats.
The result is that if a shadow is cast on any LED in the array, illuminated externally by moderate ambient light, it will light up.
<code><pre><font size=2 face='Courier'>
;HEX LED SENSOR/INDICATOR FOR 18X
;wilf rigter - 07/01/07
do
poke 5,8 ;serout=1
pins = %00000000 ;out0-7=0
POKE $AE,%11111111;out0-7=input
pause 10 ;set threshold
peek 6,b0 ;b0=out0-7
POKE $AE,%00000000;out0-7=output
poke 5,0 ;serout=0
pins=b0 xor $FF ;output b0
pause 10
loop
</font></pre></code>
The light to LED conversion process takes several steps:
1) The LEDs are reverse biased by setting serout=1 (poke 5,8) and out0-5=0. This charges the LED junction capacitance to 5V while the voltage on out0-5 is 0V.
2) pins out0-5 are configured as inputs
3) pause 10ms during which
4) the voltage on pins out0-5 starts to rise from 0V to 5V as the photo leakage current discharges the junction capacitance.
5) transfer input state of pin out0-5 to b0 (zero is read if the voltage on that pin has not decayed above the logic 0 threshold).
6) pins out0-5 are configured as outputs
7) set serout=0 (poke 5,0)
8) transfer b0 inverted to out0-5 to light the LEDs that were dark.
9) pause 10ms
10) repeat
The circuit was tested on a breadboard which adds significant stray capacitance to the circuit which increases the photocurrent controlled time constant.
PAUSE 10 sets the light threshold for the conversion. Larger values give higher sensitivity at the expense of noticable flicker as the conversion cycle time is increased.
A PCB with careful layout will give a shorter time constant and may allow multiplexing a matrix of 5x7 LED sensors.
More complex code can provide proportional light measurements for each LED.
Note that the out6 and out7 pins don't work for this application. They work fine as outputs and with switch inputs but I suspect that these are configured internally with a weak pullup resistor. More experiments will bear this out.
One application for this self illuminating LED sensor array is an art project I have in mind for a SHADOW CAST LED MIRROR which illuminates the silhouettes of passing people.
On the other hand I have used the bi-directional pins of an 08M to control a single LEDsensors to automatically start flashing when it gets dark.
On the gripping hand, hmmm... well I'm sure you'll think of something much more exciting.
enjoy
wilf
Edited by - wilf_nv on 09/01/2007 10:14:24