An LED as a light Sensor


Closed Thread
Results 1 to 13 of 13
  1. #1
    Funky Gibbon's Avatar
    Funky Gibbon Guest

    Default An LED as a light Sensor

    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

  2. #2


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Funky Gibbon's Avatar
    Funky Gibbon Guest


    Did you find this post helpful? Yes | No

    Default

    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>

  4. #4


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Funky Gibbon's Avatar
    Funky Gibbon Guest


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6


    Did you find this post helpful? Yes | No

    Default

    OK Funky
    that about sum's it up for me too you can pm anytime.talk too you later

  7. #7
    Join Date
    Mar 2006
    Location
    Garden Grove, Ca
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Led as light sensor

    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

  8. #8
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Joval
    How's that for dating myself!!!!!
    Doesn't "dating oneself" lead to hairy palms?

  9. #9
    Funky Gibbon's Avatar
    Funky Gibbon Guest


    Did you find this post helpful? Yes | No

    Default

    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

  10. #10
    John Brewer's Avatar
    John Brewer Guest


    Did you find this post helpful? Yes | No

    Default An LED as a light Sensor

    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.

  11. #11
    Join Date
    Mar 2006
    Location
    Garden Grove, Ca
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Led as light sensor

    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

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Everything else but lamps, HeathKit kits, first analog VOM... that's were the days


    Argghhh we're all old now
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    John Brewer's Avatar
    John Brewer Guest


    Did you find this post helpful? Yes | No

    Default An LED as a light sensor

    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

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Need a cheap touch sensor idea.. here it is
    By mister_e in forum Code Examples
    Replies: 20
    Last Post: - 16th April 2016, 22:42
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  4. Led as a sensor ?
    By Kman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th May 2007, 07:57
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts