LDR sensor to detect the light/dark

Thread Starter

izaty

Joined Oct 20, 2009
4
Hye all,

Just wanna ask... any of u know about LDR sensor ( detect the light/dark)?..

I am using LDR sensor... i'm used a inverted logic means... if dark=0, if light=1..

But i'm stuck with coding in order to combine it with another condition which is passing by IR sensor...

Here, i just wanna do... if LDR detect the room is dark + user pass by the sensor --> ON the light.

*************************************************

for( ;; ){



if ( PORTC.F2 == 0 ); //set LDR at PORTC pin 2
{
if ( cnt !=0 ) PORTB = PORTB | 0x08;

else if ((PORTC.F2 == 1)&&( cnt !=0 )) PORTB = PORTB | 0x00;

PORTA = SLED_A[cnt]; // activate the 1st half of the counter
PORTE = SLED_E[cnt]; // activate the 2nd half of the counter

Delay_ms(250); // delay for 250ms to generate the sensor

PORTA = 0b11000000; // receiver of IR sensor receive signal
PORTE = 0b11111100; // transmitter detect user (blue)


}
**************************************************

Hope.. anybody can help me on this...Tq
 

BMorse

Joined Sep 26, 2009
2,675
Can You post a schematic of your circuit, so I can see how the LDR is conneted?? Since an LDR gives you basically an analog output proportional to the light hitting the sensor (more light hits sensor, less resistance)....
 
Top