How to connect LDR to arduino?(HELP)

Hi everyone,

I am testing the LDR recently, but I have no breadboard,(I found most project with LDR is done through a breadboard).

My question is, can I connect my LDR directly to my arduino, and to control the LED on my arduino (13)? If it can, how to connect?

Thank you.

Sarah

If the leads are long enough you could just poke them into the appropriate header holes. If not extend them with some wire soldered on.


Rob

a) Get some breadboards! There's a nice one available from....

http://wulfden.org/TheShoppe/accessories.shtml ($6, incl p&p to USA)

or....

http://shop.moderndevice.com/collections/prototyping-breadboards-wires ($3 + P&P)

b) Go to your profile, and fill in at least a vague indication of where you are. For the breadboards, the suppliers will mail them anywhere in the world for a sensible price, although your local authorites may make a nuisance of themselves. In the UK, about 9 parcels in 10 go through with no hassle.

c) You need to connect the LDR and a fixed resistor. Covered at....

http://arduino.cc/forum/index.php/topic,66680.0.html

TO connect an LDR correctly it must be part of a voltage divider

+5V ---- [ LDR ] -----* ------[Resistor] ----- GND

Connect analog port of Arduino to * in the middle The valueof resistor must be in the same order as the LDR when in the dark. (a 10 K will work probably too)

Graynomad: If the leads are long enough you could just poke them into the appropriate header holes. If not extend them with some wire soldered on.


Rob

Could you please tell me which leads should poke into which header holes?

tkbyd: a) Get some breadboards! There's a nice one available from....

http://wulfden.org/TheShoppe/accessories.shtml ($6, incl p&p to USA)

Thank you for your reply, but I don't want to use a breadboard, I want to know if I can connect them together without a breadboard?

Well as already drawn for you:

TO connect an LDR correctly it must be part of a voltage divider

+5V ---- [ LDR ] -----* ------[Resistor] ----- GND

So, one end of the LDR goes to a +5vdc pin, one end of the resistor goes to a ground pin. Now the problem, the other ends of both the LRD and resistor must connect to the analog input pin you are using. As usually two wires won't fit into one pin hole, and you don't want to use a breadboard, then you must solder the connection between the LRD and resistor and then add a single wire from that junction connection to the analog input pin.

Lefty

but I don't want to use a breadboard

Good for you I hate those things, they are more trouble than they are worth.

I always solder stuff up an a small piece of strip board. If you keep the wires long you can always use the components again. The thing to remember is that physically you can make the topological arrangement of components any way you like. What is important is that they are all connected electrically in the right way. You tell that from a schematic.

I have got a breadboard, but with no resistor, do I have to get one, why?

retrolefty:
Well as already drawn for you:

TO connect an LDR correctly it must be part of a voltage divider

+5V ---- [ LDR ] -----* ------[Resistor] ----- GND

So, one end of the LDR goes to a +5vdc pin, one end of the resistor goes to a ground pin. Now the problem, the other ends of both the LRD and resistor must connect to the analog input pin you are using. As usually two wires won’t fit into one pin hole, and you don’t want to use a breadboard, then you must solder the connection between the LRD and resistor and then add a single wire from that junction connection to the analog input pin.

Lefty

I have got a breadboard, but with no resistor, do I have to get one, why?

Yes, you have to, there should be a flow from + to GND and the Arduino measure the voltage drop. - http://en.wikipedia.org/wiki/Voltage_divider -
If you connect the LDR to 5V and the other end to the Analog in the voltage will allways be 5 Volt as there is nothing that pulls it to GND level.

You have to form a voltage divider and take your reading from the centre (the * in the above drawing). Without two resistors (the LDR is just a special type of resistor) you are just pulling the Arduino pin low and so will always read a value of 0.

Now if for some reason you live in outer mongolia and can't get a resistor and just want to play to see what happens there are two ways to do this.

1) If you have a second LDR use that instead of the fixed resistor, as you light and shade either of the LDRs the reading will change. 2) Use the internal pullup resistor instead of the external resistor (I'm pretty sure this will work with an analogue input).

Both these methods will be very imprecise but will at least allow you to have a play.

Personally I'd just go and get a resistor.


Rob

Does anybody can post a simple Fritzing wiring diagram. I think people will be able to better understand what you mean by creating a power divider and taking the input from the middle. Thanks a lot!

robtillaart: +5V ---- [ LDR ] -----* ------[Resistor] ----- GND

it's not more than this :o maybe this is clearer (?)

+5V [ wire ] [ LDR ] [ wire ] [ wire to analog in ] [ wire ] [ Resistor ] [wire] GND

Is that a proper connection for the LDR TinkerKit sensor? I think I am getting the right reads as they vary from 20 to about 900 when put under light bulb. Resistor shown is a 10k resistor. Thank you in advance.

Is that a proper connection for the LDR TinkerKit sensor?

No, you don't need that resistor.

Everybody in all of the previous posts were saying that i need it, and without i was getting 0 as an output read, so i am guessing i need it. This set up seems to be working properly. After mapping the results from 0-1023 to 0-255 it seems to be getting me proper ranges. Why are you saying that i dont need that resistor?

If you did need the resistor, you would have to turn it 90 degrees on the breadboard. It's a short at the moment.

Yeah that graphical representation in fritzing is too big for it but physically I can bend it so that it fits vertically like that....

Let us know how that works out.

It works just fine. I hooked up a servo to it and mapped the output from ldr from 0-1023 to 0-180 and now depending on how much light falls on that sensor it adjusts servos position....its pretty sweet. Thanks for the help.