Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How do you connect LDR sensors with a PIC ??

Status
Not open for further replies.

zeeba

Junior Member level 2
Joined
Sep 26, 2010
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,424
Hi

How do you connect LDR sensors with a PIC ??

Im writting a code to read from both LDRs and show the reading on LCD and I want to see if it's working
but I dont know how to connect the LDRs with the PIC??
 

Connect the one terminal of the LDR to +5V then the other terminal to the Analog input of the PIC

---------- Post added at 13:46 ---------- Previous post was at 13:44 ----------

drskippy.net/projects/ProgrammableLED.pdf
 

I tried that it didn't work
 

Which didnt work? The LDR or the PIC? Can post your codes here?
 

Iam using assembly program to sense the sun light using 2 LDR and compare them and rotate the motor to the sun direction
 
Last edited:

It will not work with just the LDR. You need to measure voltage at one of the ADC inputs. The voltage comes from a potential divider made from a fixed resistor and the LDR in series with the ADC connected to the center. If you omit the fixed resistor the LDR will pull the PIC input high, even under dark conditions and the ADC will always read maximum voltage.

Note that there are two ways you can connect this:
1. LDR goes to the supply, resistor goes to ground.
2. Resistor goes to supply, LDR goes to ground.

Option 1 will give an increasing voltage as it gets brighter but you have to carry the supply line wherever the LDR is mounted. If it shorts to anything you could damage the supply or the wiring.
Option 2 will give a decreasing voltage as it gets lighter but this is easy to compensate in software. It has the advantage that the LDR is grounded at one end and the resistor limits the current, giving some degree of protection.

The optimum resistor value will give best voltage swing between lightest and darkest conditions. Typically, choose a value equal to the mid way between LDR dark and LDR light resistances.

Brian.
 
Connecting 5-ldr to PIC

Hi all,
We are planning to develop a Walking stick for Blinds. And we are planning to use 5 LDRs
in it to sense Vehicle lights from
1) Left
2)Front-Left
3)Front
4)Front-Right
5)Right

Above The LDRs we are planning to put some Red LEDs to knotify the vehicles that a Visually Impaired person is in front of him.
We need help in hardware designing/schematic.
If this post is considered bad then I will start a new thread :???:
else I will continue here

Thanks
Bluhole
 

It will not work with just the LDR. You need to measure voltage at one of the ADC inputs. The voltage comes from a potential divider made from a fixed resistor and the LDR in series with the ADC connected to the center. If you omit the fixed resistor the LDR will pull the PIC input high, even under dark conditions and the ADC will always read maximum voltage.

Note that there are two ways you can connect this:
1. LDR goes to the supply, resistor goes to ground.
2. Resistor goes to supply, LDR goes to ground.

Option 1 will give an increasing voltage as it gets brighter but you have to carry the supply line wherever the LDR is mounted. If it shorts to anything you could damage the supply or the wiring.
Option 2 will give a decreasing voltage as it gets lighter but this is easy to compensate in software. It has the advantage that the LDR is grounded at one end and the resistor limits the current, giving some degree of protection.

The optimum resistor value will give best voltage swing between lightest and darkest conditions. Typically, choose a value equal to the mid way between LDR dark and LDR light resistances.

Brian.

Hello,
What do you mean by "You have to carry the supply line"??
I`m using this configuration, where the resistor goes to ground. What risks are you talking about, can you be more clear please?
 

This is an old thread!

What I meant was that if the walking stick is conductive and connected to battery negative, for example many are lightweight alloys, and by it's nature likely to bump into things, it wouldn't be a good idea to run wiring from the supply to the LDRs and LEDS from the battery where it could short out and be a danger. The LDR is part of a potential divider, the other part being a fixed resistance. You measure the light level by reading the voltage at the center of the divider. If the LDR is in the ground side (more light = lower resistance = lower voltage) the fixed resistor limits the current that can flow into the LDR wires if a short occurs. If the LDR is in the supply side (more light= lower resistance=higher voltage) one of the supply lines has to travel to the LDR without any limiting resistance. This could,in some circumstances short out the battery.

Brian.
 
This is How I connect the LDR, to any microcontroller:
 

Attachments

  • photo(17).JPG
    photo(17).JPG
    2.5 MB · Views: 110

Warning: if the potentiometer is set to zero Ohms (short circuit) and a bright light shines on the LDR it could burn it out. Always add a fixed series resistance to limit the LDR current. The transistor is almost irrelevant in that circuit, the volage can be taken from across the LDR itself.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top