LDR project

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

LDR project

Postby wkkent » Thu Jun 14, 2012 6:41 pm

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
wkkent
Fledgling
 
Posts: 1
Joined: Thu Jun 14, 2012 6:37 pm

Re: LDR project

Postby kl84 » Fri Jun 15, 2012 11:02 pm

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...
User avatar
kl84
Amateur
 
Posts: 166
Joined: Thu Jul 08, 2010 12:14 pm


Return to Sensor

Who is online

Users browsing this forum: No registered users and 22 guests

cron