Arduino + Photo Resistor circuit (newbie help)

Hi,

I have a Phototransistor that, when given IR light outputs about 0.10V..
I assume it would be easy to read it with analog input and some threshold logic, but, i would rather have it output high or low..

So my question is, can I make the phototransistor have a base 3.95V or so, so when the IR hits it the voltage goes 4.05V (and HIGH on input)?

Or how does one generally sort this thing out? :slight_smile:

With no IR the output from the transistor is 0V.

Wire up the emitter to ground and the collector to the arduino input. Also wire a 100K resistor from the arduino input to the +5V line.

If this does not give enough voltage swing increase the 100K resistor to 200K or some such value.

Hi, thanks for the replies!
I havent gotten aroudn to trying the circuiting you proposed yet.

I did however find the datasheet for the transistor im using;
http://pdf1.alldatasheet.com/datasheet-pdf/view/115402/ETC/PT928-6C.html

I would like to get a digital HIGH whenever its NOT hit with IR light..
Is that as easy as wiring a 100k resistor like Grumpy suggested?

I would like to get a digital HIGH whenever its NOT hit with IR light

There is no point in doing this as it is much simpler to change over the logic in software if required.

Ok.

I have wired a ~250k resistor to the phototransistor and while being it with IR its voltage is around 2.36V

When i block the ir emitting diode, it goes up to 3.65, however, the Arduino digitalread() says that 2.36V is High.. i thought only values over 3 counted as high?

How can I sort this out? :slight_smile:

Reading some more I assume I have to make it be less then 2V when being lit, and >3V not being lit, to get reliable values?

So in my case, I could pick a higher value resistor?

Simply use the analogue input and compare what you read with a threshold value. If it is above the threshold then do one thing if it is below then do another. There is no need to condition the signal into a digital one.

i thought only values over 3 counted as high

Over 3V is is guaranteed to read as high under 1V it is guaranteed to read low. Anything in between is not guaranteed to read any level but as it is a digital input it will always return either high or low. Normally it continues to return the last true value it read.