 ldr value inverted

First i used the method from the book "getting started with arduino", then someone told me it's wrong:

I think the LDR is set up wrong. The way that works for me is:

+5V-----[resistor]------ --------[LDR]--------Gnd | | | | Arduino pin

This forms a voltage divider; the voltage on the arduino pin is therefore dependant on both the fixed resistor resistance and the LDR resistance/

Onions.

My "wrong" method worked btw (but it could burn my LDR out after a while i was told):

+5V-----[LDR]-----[RESISTOR]--------Gnd | | | | Arduino pin

Anyway, before the more light there was coming in the ldr the higher the value was. Now it's the other way around, the darker it get's the higher the value, even if i rotate the ldr 180degrees. I can easilly fix it by code to get the result i want, however i would like to understand why this is cause it doesn't make sense to me.

it is in the voltage divider. suppose the LDR is sensing some light change so that it's resistance is getting smaller.

in the first picture, the voltage at the pin is getting lower. to see why this is, suppose the resistance of the LDR could become zero, then it is clear the arduino pin is directly connected to ground.

now do the same reasoning for the second circuit. the LDR becomes 0 ohms (same as above, same light change, resistance of LDR is getting lower) but in this circuit having a 0-ohm LDR means the arduino pin is now connected to the Vcc.

that is how the sequence of resistive elements in your voltage divider influences the signal on the pin.

Ps I'm no expert on LDR's, but since the arduino pin will not draw a lot of current if programmed correctly, the total current thru the LDR is solely based on the value of the resistor. in both circuits. as long as that mximum current is safe for the LDR, it does not matter which of the two circuits you use. (use ohms law : 5 volts = your resistor in ohms x the current you want to calculate; that means 5 volts / resistor = current you want to know; then compare that current with whatever documentation you have on that LDR)

What is the value of the resistor used?

a) Does anyone see how the "bad" circuit... AS LONG AS it is an Arduino on the "output" leg, and as long as the Arduino pin concerned remains configured as an input... could damage the LDR?

b) For another explanation... nothing new, just said another way... of voltage dividers, see...

http://www.arunet.co.uk/tkboyd/ec/ec1voldiv.htm

It is a new page... I would appreciate feedback on bits that help and bits that are still obscure.

Voltage dividers are enormously useful. If you understand them you will use them in all sorts of ways. (If you don't understand them, various circuits will give you problems, and may damage components!)