LED as LDR

hwinther

New Member
I apologize if this has been asked and answered before, i found something about it on this forum but it didnt include any details, and my search phrases gave too many results...

Anyhow, im trying to get some leds to work as light sensors, or rather - to use them as touch-switches. Im getting fair adc inputs with some of my "wide angle" LED's but the stronger and thus narrower ones dont seem to be adequate.
Currently im using a 10K resistor and im getting ADC values that are over 200 unless i use a flashlight, and the reverted digital input is always 0.

I'm including my source code in case my pauses are incorrect:

high 1
low 2
high 4
pause 2000
pins=0

start:

dirs=%000001110 '1,2=output
high 1 'source
low 2 'sink
pause 10 'wait 10ms

'reverse bias it
low 1
high 2
pause 10

dirs=%000001010 '1=out 2=in
pause 1
b0=pin2 'read state
b0=b0^1 'invert the result
readadc 2,w1
debug

if b0 = 1 then LEDON
goto start

LEDON:
high 4
goto start
 

hwinther

New Member
Oh yeah.. i forgot to phrase my actual question; Those of you who have experimented with this: how did you manage to get a usable digital input signal? Do have to use op-amps?
 

hippy

Ex-Staff (retired)
I never got a LED signal high enough to work with digital inputs, only analogue, so I guess an op-amp plus comparator / schmitt gating is the best way. You could try runing the PICAXE at its lowest voltage which, relatively speaking, increases the LED voltage out. Or simply stick with using READADC.

None of the reverse biasing tricks worked for me as it seems the input has to be read very soon after ( microseconds ), and the PICAXE is just too slow.

I also found that LED's were not very responsive away from a natural light source anyway, and IR LED's performed best for that.
 

Michael 2727

Senior Member
You could try playing with the ACD pulldown
resistor.
Up to 100K may still work for some applications, down to 1K for others.
Experiment.

You won't get much out of an LED, the best
way would be to use an OP Amp.
 

inglewoodpete

Senior Member
LED + OP AMP = complicated (but you may have the parts already)
PhotoTransistor = simple (but you may not have one "in stock")
 

hwinther

New Member
Thanks for the input, I'll be getting some op-amps to get a basic switch working then. But the phototransistor wouldn't be any good here as i want it to be two way. Also i tried different resistors and it didnt seem to make much of a difference

But if i could make the ADC convertion go faster that would probably be the easiest way to solve this.. which makes me think of using higher clocked chips or maybe external ADC chips..
Perhaps the new 28X2 at 40MHz would be fast enough to convert the ADC value without the LED flickering.
 
Top