Analog Input Problem

I'm a newbie, so bear with me.
I used an LDR with Arduino Uno on the 1.6 IDE to determine the value of the analog input the LDR gives back. I made a standard circuit with one pin of the LDR connected to 5V and the other pin connected to Ground and A0 (Analog Input) on the Arduino . However, on the Serial Monitor, I am constantly getting a reading of 0.
Can anyone help me with that please ?

A direct short to ground beats an LDR every time.
Try a voltage divider (good search term there) instead.

Thanks for the reply AWOL.
However, how will the usage of a voltage divider solve the problem ? And if you are not busy, do you have a schematic for that particular case ?

However, how will the usage of a voltage divider solve the problem ?

I don't know what the problem is, but I also don't know what your idea of "a standard circuit" is.

I gave you the search term, it's a very simple circuit (probably only one more component than you already have), so why don't you try it?

Hey, look, you connect the LDR from A0 to ground. No other connection.

Use pinMode(A0 , INPUT_PULLUP) to switch on the pull-up.

Now read the analog input.

Hey AWOL !
I can't understand your point. This is the schematic I am currently using . Please omit the 10k resistor, I used a standard random value resistor in its place.

That's not what you described in your original post.
Why didn't you post that earlier?

I used a standard random value resistor

Oh, that's OK then.
Just as long as it's standard random, and not just any old random.

Hey Paul_B !
Is it necessary to define the LDR as a pullup resistor ? Can't I just read the values directly if I want to, using your idea ?

Hey AWOL !
I'm sorry for using this useless jargon ("standard"). What do you think is the problem ? In layman's terms please. :slight_smile:

adeelshams:
Is it necessary to define the LDR as a pullup resistor? Can't I just read the values directly if I want to, using your idea?

I suggest you follow exactly my instructions.

Hey Paul_B !
Thanks, I'll do it right now !

The LDR has a light dependent resistance.
It lets some, none to almost all, of the 5V current through.

The resistor to ground line drains that current.
It is slowed down by the resistor.

In between there is a reduced current that because the current flowing through the two resistances MUST be the same ends up at some less than 5 volts. That voltage is 5V times a ratio of the two resistances and it is what the analog pin gets.

There's two laws that determine that, Ohm's Law and IIRC Kirchoff's Law (probably have that one wrong). You need those to figure out most of the simpler circuits you might be wiring to Arduino.

I get it.
Thanks GoForSmoke !

I forgot to add... that if the resistor to ground is a big value the LDR at small values will approach 5V.

Try graphing analog value as a function of LDR value and the pulldown resistance.
That should tell you something about choosing a resistor.

The first thing to do is measure the resistance of the LDR with a multimeter to see what sort of
value it is at the levels of illumination you are using. That will also tell you if its broken or not.

Then pick a fixed resistor of the same magnitude of resistance to form a divider.

There's a very good tutorial on LDRs here at adafruit.

JimboZA:
There's a very good tutorial on LDRs here at adafruit.

Although it unhelpfully refers to them as "photocells". :astonished: