LDR

Project 9 – Analog Sensor: Light detection using LDR

PROJECT 9

ANALOG SENSOR: LIGHT DETECTION USING LDR

Back to Project 8                                                                                                       Go to Project 10

A photoresistor or light dependent resistor (LDR) is a resistor whose resistance decreases with increasing incident light intensity. It can also be referred to as a photoconductor. In here, we going to do a simple connection of LDR and display the ADC and Voltage value on LCD.

———————————————————————————————————————————————————-

COMPONENT NEEDED

———————————————————————————————————————————————————-

  16 x 2 LCD Display
   LIGHT DEPENDENT RESISTOR
   1K RESISTOR
   BREADBOARD
   JUMPER WIRES

———————————————————————————————————————————————————-

CONNECTION

———————————————————————————————————————————————————-

There are 2 way of constructing the voltage divider which is LDR on top or LDR on bottom.

LDR ON TOP
Refer to the figure below, there are total 3 wires using. RED wire connect between LDR and VDD. Black wire connect between resistor and GND. Lastly, YELLOW wire are connect between RA0 and between LCD and resistor. Please refer this webpage for further detail.

LDR ON BOTTOM
Refer to the figure below, there are total 3 wires using. BLACK wire connect between LDR and VDD. RED wire connect between resistor and GND. Lastly, YELLOW wire are connect between RA0 and between LCD and resistor. Please refer this webpage for further detail.

———————————————————————————————————————————————————-

ADDITIONAL INFORMATION

———————————————————————————————————————————————————-
MEASURING RESISTANCE OF LDR
To measure the LDR resistance, just probe directly +ve to one side of LDR and -ve to the other side of LDR.

LDR VOUT MEASUREMENT

In this case, we give the Vin as 5V and resistor are 1K.

E.g-1: LDR on Top, Rtop = 10K
Vout = 1K x 5V
1K + 10K
= 0.45V

E.g-2: LDR on bottom, Rbottom= 10K
Vout = 10K x 5V
10K + 1K<
= 4.54V

———————————————————————————————————————————————————-

CODE OVERVIEW

———————————————————————————————————————————————————-

for (i=0 ; i<10 ; i++)
{
adc_value = adc_value + ui_adc_read();
}
Read and store the ourput value of ADC for 10 times.

adc_value = adc_value/10;
Divide the adc_value by 10 times to get the average result.

volt_value = (adc_value*50)/102.4;
Same as project_4, to display the output in voltage, we need to recalculate the adc_value given and times with 50 and divided by 102.4.

Back to Project 8                                                                                                       Go to Project 10

———————————————————————————————————————————————————-

ATTACHMENT

1. P9 user manual.pdf
2. Project_9_code.zip

Buy

, , , ,

Related Post

20160330_085520-e1459299689529-400x323

Control and Monitor via SMS Part 2

ciku-7-400x347

Simple steps to control Stepper Motor using 2Amp Motor Driver Shield and CIKU

18f4550arrowclock

PIC16F VS PIC18F:Analysis of PIC Mid-Range 8 bit family and Advanced 8-bits Family

10587-600x800

Using MDD10A with CIKU

5 thoughts on “Project 9 – Analog Sensor: Light detection using LDR

  1. Hi, tonynwk88

    Would you mind to share more details of this LDR project with me? Is there a ‘project kit’ available for sale?

  2. for me it showing this error when i tried compiling. plz advice me

    Build C:\Users\HK\Desktop\Project_9\Project_9 for device 16F887
    Using driver C:\Program Files\HI-TECH Software\PICC\9.83\bin\picc.exe

    Make: The target “C:\Users\HK\Desktop\Project_9\adc.p1” is out of date.
    Executing: “C:\Program Files\HI-TECH Software\PICC\9.83\bin\picc.exe” –pass1 C:\Users\HK\Desktop\Project_9\adc.c -q –chip=16F887 -P –runtime=default –opt=default -D__DEBUG=1 -g –asmlist “–errformat=Error [%n] %f; %l.%c %s” “–msgformat=Advisory[%n] %s” “–warnformat=Warning [%n] %f; %l.%c %s”

    Error [192] C:\Users\HK\Desktop\Project_9\adc.c; 117.1 undefined identifier “GODONE”

    Make: The target “C:\Users\HK\Desktop\Project_9\lcd.p1” is up to date.
    Make: The target “C:\Users\HK\Desktop\Project_9\Project_9.p1” is up to date.

    ********** Build failed! **********

  3. hari25,
    Try use GO_DONE instead of GODONE.
    The causes is from different version of Hi Tech C Compiler.
    If you still experience the same problem pls discuss in our technical forum.

  4. hello
    the code has been compiled successfully , but the voltage is not changing . its fixed .

Leave a Reply

Your email address will not be published. Required fields are marked *