Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LDR Sensor

Status
Not open for further replies.

shico90

New Member
Hello,
I'm building a light sensor to detect light and give a pulse to the micro-controller
So I used a LDR sensor and I connected one pin to the VCC and the other to the micro-controller so that when it detects light, it short circuits and give 5 volt to the controller and when there is no light, the resistance of the LDR becomes very high and gives zero voltage to the controller.
That is all theortical but when i tried it, I found that when there is no light the LDR gives about 2 volt and i want it to give zero voltage to the controller
the LDR is so sensitive and catches any beam
Is there is anyway to make its sensitivity less than that?
 
Sure, make a voltage divider by adding a resistor between the MCU port pin and the MCU's Vss (Gnd) Pin. The best value for the resistor is that it have the same resistance as when the LDR is "half illuminated" (not dark, not full illumination).
 
So can I connect the LDR directly to the MCU without the need of ADC?

Well, the trip point of a digital input to a MCU is not all that stable or well characterized. Typically, the logic threshold is about 2V, so if the output of a voltage divider consisting of the LDR to Vcc and a resistor to Vss is tied to a port pin, the MCU will get "1" if the voltage at the tap is >~2.2V, and it will get a "0" if the voltage is < ~1.6V. What happens between those voltage is your best guess.
 
u should not connect LDR direct to uc port cause interpretation of voltage level is different. uc uses digital logic. if you want only detect dark or bright, u should use op-amp as comparator. But if you want to apply LDR as intensity meter, use ADC.
 
You might want to consider studying an existing circuit tha has an LDR on it, in a voltage divider. The uprocessor used is a PIC16F88. It has a bootloader code built in so you can use the free compiler to write code and use a serial port (USB in this case) to load in the finished code. Here is the data sheet for this board, the Nano Simon, complete with demo codes and a schematic with the LDR in it.
https://www.electro-tech-online.com/custompdfs/2010/09/7seg_led_Simon_game_Nano_B0117.pdf
The LDR code is about half way into the data sheet, the schematic is towards the end.
kenjj
 
Hi,
If you are using a microcontroller that has comparators than you can use the internal comparators, saves the hassle you get with ADC although it does use up one more pin.
 
hi sir/ma;am..
How can i download the *.pdf you had posted??? I tried to search it to the internet but i didnt able to find it... Thank you.

Click on the link and in the dialog box you see choose save file or just open the link in Acrobat Reader (if you have it) and once open click file and choose Save A Copy from the menu.

Ron
 
You should be able to connect the LDR directly to the uC without the need for a comparator. Connect it between Vdd and an input pin which has a Schmitt function. Connect a suitable pull-down resistor between the pin and Vss. The Schmitt trigger level is a fairly stable fraction (albeit within some tolerance range) of Vdd.
 
Status
Not open for further replies.

Latest threads

Back
Top