The connection is as follows An infrared sensor circuit which yields 0 or 5v depending on closed or open circuit output line to port 2_0 pin of microcontroller 8051 philips.Problem is when i do this the circuit value are overridden by the current value on port 2_0 led always goes on.Here is my code(in keil c) i guess i have not configured P 2_0 as input properly
void MSDelay(unsigned int);
sbit led=P1^0;
void main()
{
unsigned int var;
P2=0xFF;
TMOD=0x20;
TH1=0xFD;
SCON =0x50;
TR1=1;
while(1)
{
var=P2^0;
if(var==0)
{
led=1;
SBUF='0';
while(TI==0);
TI=0;
MSDelay(250);
}
else
{
led=0;
SBUF='9';
while(TI==0);
TI=0;
MSDelay(100);
}
}
}