This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem while giving input to 8051

I have use following code for 8051 by NXP(p89v51rd2)

#include<reg51.h>
#define p2 P2
sfr P1=0x90;
sbit led1=p2^0;
sbit s=P1^0;

void main()
{
        s=1;
        while(1)
        {
                if(s==0)
                {
                        led1=1;
                }
                else
                {
                        led1=0;
                }
        }
}

I have connected led on port 2 (pin no. 0)
circuit of sensor is here elecrom.wordpress.com/.../

this sensor on black background generate 0 to 1.5 Volt

when i connect ground to port 1 via 1k led glow but when i give output from sensor (IR sensor) output volt of sensor increase to 5V.
Is there something wrong with program?