How to Connect Phototransistor to PIC

Thread Starter

JDR04

Joined May 5, 2011
367
I'm hoping somebody would be able to help me out with this.

I'm wanting to connect a phototransistor (which will be used to detect ambient light) to a microcontroller but I am not sure which method is the correct or best one.(See attached Schematic) If neither are advisable could you please show me the correct method.

Thanks in advance.........JDR04
 

Attachments

MikeML

Joined Oct 2, 2009
5,444
Method 1 will not work at all...

Method 2 is better, but is highly dependent on the resistance vs illumination curve of the specific photo-detector you select. If you connect it to a Digital input on the uP, to get a logical zero when the detector is not illuminated, the value of R3 will have to be adjustable over the range from ~2K to about ~100K, depending on where you place the photo-detector, and the specific detector you choose...
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
28,687
Also depends on if you are using an analogue or digital input, if digital, you may want to add a comparitor, LM311, between the sensor and the uP input to get a little snap action input.
Max.
 

Thread Starter

JDR04

Joined May 5, 2011
367
method 2 certainly.
split the resistor value and add a pot. to the string to allow a sensitivity adjustment
I did not show it but I plan to have a 100k pot on another pin to set the threshold before triggering. Thanks for the suggestion.
 

Thread Starter

JDR04

Joined May 5, 2011
367
Also depends on if you are using an analogue or digital input, if digital, you may want to add a comparitor, LM311, between the sensor and the uP input to get a little snap action input.
Max.
Thanks. I have hysterisis (I think its called) built into the programming.
 

DickCappels

Joined Aug 21, 2008
10,179
It sounds like you are looking at the light dependent resistor through the A-to-D converter; good choice because that gives you the flexibility to deal with the details in firmware.

You will have to adjust the value of the resistor to suit your particular light dependent resistor and your application. The 100k pot is a good way to find the ideal resistance.
 

John P

Joined Oct 14, 2008
2,026
A phototransistor isn't very good for detecting light level, because they typically don't match the response of the eye very well. You'll get a huge response from daylight or incandescent, for instance, and not much from fluorescent light. You'd do better with a cadmium-sulfide photoresistor. At least check the response curve of the part you plan to use, and compare with the type of light you expect to see.
 

#12

Joined Nov 30, 2010
18,224
Could I ask as to how one determines the resistor values?
Reality testing. I went through all this with some CdS cells I had. None of them resembled each other. I learned that the full moon is about 1/2 of a foot candle and daylight is about 100,000 foot candles. Having no way to produce the in-between amounts and measure them, I just sat in the back yard and watched the ohm meter until I thought it was time to turn the lights on.

One experimental result is worth a dozen theories.
 

ScottWang

Joined Aug 23, 2012
7,400
You didn't show what is the uC and what are you trying to detect the ambient light for?
And what is the phototransistor or you want to change to using a CDS?
 

Thread Starter

JDR04

Joined May 5, 2011
367
Thanks to everyone, I'll work on all the suggestions and see what best suits my need. Thanks a lot.....JDR04
 
Top