Page 1 of 1

LDR project

PostPosted: Thu Jun 14, 2012 6:41 pm
by wkkent
I am new in C programming.

My project is using 16f877a + LED + LDR...

the description of the project is as below:
When its dark, LED blinking
When its light, LED off

coz of the tutorial only teaches me how to print the value of LDR in LCD.... i do not know how to relate the LDR to LED... can someone please help me in the source code? thanks

Re: LDR project

PostPosted: Fri Jun 15, 2012 11:02 pm
by kl84
Since you know how to get the LDR value by referring to Cytron's tutorial, you can make use of that value. Eg:

CODE: SELECT_ALL_CODE
if ( LDRvalue >= 300 )
{
    LED = 1;
    delay();
    LED = 1;
    delay();
}
else
{
    LED = 0;
}


This depends on how you connect the LDR. I don't know how Cytron connects it in their tutorial. You should check. So it could be >= any value OR <= any value...