View Full Version : An LED as a light Sensor
Funky Gibbon
- 1st April 2006, 13:24
Hello,
Im new to this forum and i dont know if this subject has been covered before but i just had to share it as i think it's coolest thing i've ever seen
We all know LED's emit light, did you know they can be used as a photodiode too?
I've read the theory, tryed it and yes it works, the theory is simple to understand if you are familiar with rc time
Take a look at the video here
http://mrl.nyu.edu/%7Ejhan/ledtouch/index.html
then read the theory here
http://www.merl.com/reports/docs/TR2003-35.pdf
im sure you'll be amazed too, or mabey im just easily pleased, if anyone has difficulties in coding the theory im quite willing to share my own code written in ASM & Proton
bbarney
- 1st April 2006, 15:31
That is a really neat idea with some really good potential.
I would be interested in your code and I think GCollier might be too
bbarney
Funky Gibbon
- 1st April 2006, 17:14
Hi BBarney
This is my basic get you going proton code, there are alot of improvements that can be made, the procedure is:
LED + connected to portb.1
LED - connected to portb.0 through 330ohm resistor
You will find that the led will flas fast in normal light, and slow in dark, my codes have some timing issues and are by no means perfect but they should give you the bulding blocks
<code>
device = 18f452
xtal = 20
dim timer as word
start:
output portb.0 'make pin output
output portb.1 'make pin output
high portb.1 'make led + high
low portb.0 'make led - low led lights up
delayms 20 ' small delay
low portb.1 'make led + low
high portb.0 'make led - low reverse bias led
timer = 0 'clear timer
input portb.0 make led - an input
loop:
if portb.0 <> 0 then timer = timer + 1 : goto loop 'if led - is not at logic low then increment timer and loop until it is logic low
serout porte.1 , 84, [dec timer,13,10,0] ' sent the result to serial lcd
goto start
stop
end
</code>
This is the same in ASM except im using porta.7 & 6 for led
<code>
LIST p=16f628a
#include <p16f628a.inc>
ORG 0000h
START
MOVLW 7
MOVWF CMCON
BSF STATUS, RP0
CLRF TRISB
BCF STATUS, RP0
MAIN
BSF STATUS, RP0
MOVLW b'00000000'
MOVWF TRISA
BCF STATUS, RP0
BSF PORTA, 7
BCF PORTA, 6
CALL DELAY
BCF PORTA, 7
BSF PORTA, 6
MOVLW 0
MOVWF TMR0
BSF STATUS, RP0
MOVLW b'01000000'
MOVWF TRISA
BCF STATUS, RP0
LOOP
INCF TMR0, 1
BTFSC PORTA, 6
GOTO LOOP
MOVF TMR0, 0
MOVWF PORTB
GOTO MAIN
DELAY
MOVLW 0FFh
MOVWF TMR1L
MOVLW 0Ah
MOVWF TMR1H
DELAY_INNER
DECFSZ TMR1L, 1
GOTO DELAY_INNER
MOVLW 0FFh
MOVWF TMR1L
DECFSZ TMR1H, 1
GOTO DELAY_INNER
RETURN
END
</code>
bbarney
- 1st April 2006, 17:39
Thank's for the code Funky
I'am working on something at the moment but I'll be playing around with this idea just as soon as i can get my other project done.I'll keep in touch
bbarney
Funky Gibbon
- 1st April 2006, 18:02
OK BBarney
I should point out that the code is mine but the original concept is'nt so i can't take any credit for the idea, also it is a new concept to me also so im at the learning stage.
i'll post updates on progress, there is some potential here for applications, not everyone has got photodiodes in their bit boxes but just about everyone has an led kicking around somewhere, besides i like the idea of using a device as emiter and sensor in one package
bbarney
- 1st April 2006, 18:07
OK Funky
that about sum's it up for me too you can pm anytime.talk too you later
Joval
- 6th April 2006, 05:17
Hi,
I used leds years ago as light sensors for a solar tracker. I also remember taking the cap off of a ck722 transistor (Some of the first commercial transistors) and using it like a phototransistor.
How's that for dating myself!!!!!
Joe
dhouston
- 6th April 2006, 12:12
How's that for dating myself!!!!!
Doesn't "dating oneself" lead to hairy palms?
Funky Gibbon
- 6th April 2006, 20:01
Aparently so Joval, as far back as 1978 it says in the pdf i read, and their only just telling us now? BTW i hear Veet works well on them Palms, lol
John Brewer
- 7th April 2006, 23:30
Don't worry about dating yourself?... Remember the OC71 germanium transistor and the OCP71 photo transistor. They were the same device but the OC71 was covered in black paint and cost 10 times less than the OCP71 so we used to scrape the paint off! The manufacturers retaliated by filling the OC71 with opaque paste. We got around this by attatching the transistor by its legs into a spin dryer and driving the paste down away from the junction. Those were the days! John, PIC newby.
Joval
- 9th April 2006, 06:46
All,
Thanks for the comments!!! YOUNG WHIPERSNAPPERS!!!!
Yea, those were the days before the 2N nomenclature. Remember well the OCs and the transistor gain testers.
Joe
mister_e
- 9th April 2006, 09:34
Everything else but lamps, HeathKit kits, first analog VOM... that's were the days
Argghhh we're all old now :)
John Brewer
- 10th April 2006, 18:43
Yes, I still have my Heathkit OS-1 oscilloscope. It was built and owned by the late ill fated Don Crowhurst around 1964. I marvel at these modern PICs, they would have made our lives so much easier :-)
JohnB
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.