why do I need a pull down resistor when using an LDR?

Hi,

A total newb-question here, sorry. I'm aware that I need to use pull down/up resistors when using buttons and the likewise into the arduino, but when using an LDR, since it's a resistor in itself, I don't understand why I also need a pull down resistor as described here: http://learn.adafruit.com/photocells/using-a-photocell

I tried doing this without the extra resistor, but then my readings were just 0 all the time.

At first I thought that I was making a short circuit, but I don't see how I can make a short circuit when there's already a resistor (the LDR) between ground and 5v.

Søren

The resistor is not so much a pull down resistor but part of a voltage divider.

I see, but the analog in pin (with analogRead) should be able to read values between 0 and 5 volts as far as I know, so why would I need to reduce this voltage ?

the LDR is a light diode - now the key word "Resistor"

two resistors forms a voltage divider...

cjdelphi: the LDR is a light diode - now the key word "Resistor"

The D in "LDR" is for Dependent, [u]not[/u] diode.

soeren:
I see, but the analog in pin (with analogRead) should be able to read values between 0 and 5 volts as far as I know, so why would I need to reduce this voltage ?

I tried doing this without the extra resistor, but then my readings were just 0 all the time.

At first I thought that I was making a short circuit, but I don’t see how I can make a short circuit when there’s already a resistor (the LDR) between ground and 5v.

The Light Dependent Resistor only has two leads. Which lead did you expect to change, the one attached to +5V or the one attached to ground?

I'm not the greatest person at explaining things but here goes... As you have already found out, to read the resistance of an LDR you need to measure voltage difference across the resistor. If you just connect the LDR between 5V & GND and connect the analogue input pin to the lower GND side then despite the LDR resistance changing you will only measure the potential difference between AREF (5V) and GND. When you put the LDR in series with another resistor and move the analogue input between the two resistors your then measuring the voltage drop between AREF (default 5V) and the second resistor input (that has the potential of being between 5V and 0V depending on how resistive the LDR is). The resistance value of the second resistor is not critical though it need to be reasonably high that the current draw is insignificant if the LDR was 0 ohms.

soeren: I see, but the analog in pin (with analogRead) should be able to read values between 0 and 5 volts as far as I know, so why would I need to reduce this voltage ?

Because you only measure voltage at the analog pin, not resistance. The LDR changes resistance with light. To turn a change of resistance into a change of voltage you need to pass a current down it. That is done with your pull up resistor.

[quote author=Runaway Pancake link=topic=170175.msg1265736#msg1265736 date=1370359552]

cjdelphi: the LDR is a light diode - now the key word "Resistor"

The D in "LDR" is for Dependent, [u]not[/u] diode. [/quote]

oh man, you got me!.... when's the trial?

cjdelphi: oh man, you got me!.... when's the trial?

Your plea has been entered. We'll move on to sentencing without further ado.

Grumpy_Mike:

soeren: I see, but the analog in pin (with analogRead) should be able to read values between 0 and 5 volts as far as I know, so why would I need to reduce this voltage ?

Because you only measure voltage at the analog pin, not resistance. The LDR changes resistance with light. To turn a change of resistance into a change of voltage you need to pass a current down it. That is done with your pull up resistor.

OK, I still don't quite get the logic of it. When I put a 220 ohm resistor I get quite low voltage between the resistor and LDR, but when I place a 10kohm resistor I get "much" higher voltage (less voltage drop) - how does this work out? How can more resistance give higher voltage? I thought it would lower voltage, but I must be misunderstanding something here obviously.

What's actually happening is that the pull down resistor is "drawing" the current into gnd, is that right? And if I don't have a pull down resistor the voltage won't "flow" that way.

When I measured the voltage on the gnd side of the LDR (without a pull down) I got absolutely 0 voltage..

I'm sorry, I think maybe I need some kind of logical explanation if that's possible :)

Søren

5v-----[R1 100ohm]-----[R2 1000ohm]-------gnd ........................Vout

So the key to triggering off the transistor is get a voltage out when it goes dark or when it goes light, so let's say we want it to go dark

LDR 10ohms = super bright LDR 100,000ohms = Dark LDR 1000ohms = Normal Light

5v-----[R1 2000 ohm Light Dependent Resistor]--*VOUT---[R2 1000ohm]-------gnd So, here we have 2000 ohm and 1000ohm for your total resistance.

3000ohm RT correct.

Amps = 5/3000 = 0.00166 amps

So at that point in time, Vout = 0.00166 * 2000 = 3.333333333333333v where as. a high light value reading would show something like, 1 ohm for the LDR.

TR = 1001ohms TC = 5/1001 =0.004995004995005amps

So Vout = 0.0049v

So when it's dark, Arduino will read a bright, it will be off, and when it's dark it will be on, re-arrange the resistors to make it do the other way round... look up ohms law (larger the value eg more ohms, the greater the voltage drop across it.)

When I put a 220 ohm resistor I get quite low voltage between the resistor and LDR, but when I place a 10kohm resistor I get “much” higher voltage (less voltage drop) - how does this work out?

This is a potential divider, see:-

And if I don’t have a pull down resistor the voltage won’t “flow” that way.

Voltage NEVER flows, it is current that flows. A current flowing through a resistance causes a voltage to be developed across that resistance. The relationship between current flow, voltage and resistance is called ohms law.

When I measured the voltage on the gnd side of the LDR (without a pull down) I got absolutely 0 voltage.

Yes you will, why do you think this is odd? People keep telling you an LDR does NOT generate any voltage it is just a Light Dependent Resistor.

I think maybe I need some kind of logical explanation if that’s possible

Well every reply in this thread is a logical explanation, you have to do your bit by saying what bit of the logic you don’t understand.

[quote author=Papa G link=topic=170175.msg1265761#msg1265761 date=1370360782]

soeren: I see, but the analog in pin (with analogRead) should be able to read values between 0 and 5 volts as far as I know, so why would I need to reduce this voltage ?

I tried doing this without the extra resistor, but then my readings were just 0 all the time.

At first I thought that I was making a short circuit, but I don't see how I can make a short circuit when there's already a resistor (the LDR) between ground and 5v.

The Light Dependent Resistor only has two leads. Which lead did you expect to change, the one attached to +5V or the one attached to ground? [/quote]

By "change" you mean read the voltage value at that specific point, or? I want to read the voltage on the LDR lead that goes to ground.

Grumpy_Mike:

When I put a 220 ohm resistor I get quite low voltage between the resistor and LDR, but when I place a 10kohm resistor I get "much" higher voltage (less voltage drop) - how does this work out?

This is a potential divider, see:- http://en.wikipedia.org/wiki/Voltage_divider

And if I don't have a pull down resistor the voltage won't "flow" that way.

Voltage NEVER flows, it is current that flows. A current flowing through a resistance causes a voltage to be developed across that resistance. The relationship between current flow, voltage and resistance is called ohms law.

When I measured the voltage on the gnd side of the LDR (without a pull down) I got absolutely 0 voltage.

Yes you will, why do you think this is odd? People keep telling you an LDR does NOT generate any voltage it is just a Light Dependent Resistor.

I think maybe I need some kind of logical explanation if that's possible

Well every reply in this thread is a logical explanation, you have to do your bit by saying what bit of the logic you don't understand.

1st quote: I know that it's a voltage divider, but I think I'm generally a bit confused why I need to measure the output voltage between R1 and R2. Why not after R2, or even without R2 and then measure voltage after R1?

2nd quote: I'm sorry, wrong use of words. I meant current of course.

3rd quote: So a normal reistor generates voltage, but an LDR does not? Aha. It seems odd to me because they are both resistors - I mean, they "make" resistance in the circuit - but there most be something I'm not getting right obviously. Please bare with me, it's a great help all the things people have written already. I really prefer discussing the matter with someone instead of finding out everything on my own (I spend quite a lot of time doing that, heh).

4th quote: I'm really trying to express myself specifically as to where my lack of knowledge is. Is there anything in particular you would like me to elaborate on?

Maybe the hydraulic analogy will help. Look at the section here titled ‘Voltage Law and Pressure’ and note the lb/in2 - volt values at the base of the single resistor and the double resistor circuits.

So a normal reistor generates voltage, but an LDR does not?

No. No resistor generates voltage. A voltage is never generated by a resistor of any sort. A voltage drop is produced when current flows through a resistor be it LDR or any sort. However if you just put a voltage across a single resistor current will flow but the voltage dropped will be the voltage you apply so there is no point in measuring it, it will always be the same no matter what the resistance is.

I know that it's a voltage divider, but I think I'm generally a bit confused why I need to measure the output voltage between R1 and R2. Why not after R2, or even without R2 and then measure voltage after R1?

Again wrong words. Not between R1 and R2 but at the junction of R1 and R2. Without two resistors you would just get a measurement of 5V because that is what is supplying the resistor. You need two resistors so you can "see" the effect of the current flow. There is no easy way to measure current flow through a single resistor.

If you measure the voltage after R2, you will always get 0V as the point is at ground. It won't help you get a measure of the change in resistance of the photocell. If R2 is removed, again it results in a fixed voltage. In that case, there is only a single resistor whatever voltage you are applying from the battery appears across it whatever the value of the resistance is. When you use a voltage divider, it ensures that the voltage at the mid point of R1 and R2 changes with respect to variation of resistance of R1& R2. You can calculate the voltage using V= 5*(R2)/(R1+R2), assuming that you applied a 5V across the divider.