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

led lighting at a pin

.
Is the code given below correct?If not please tell why?
<
#include<reg51.H>
sbit IN = 0x90;
sbit OUT = 0xA0;
void delay(unsigned int);
void main()
{ while(1)
{ P1 = 0xFF;
P2 = 0x00;
while(IN == 1)
{ OUT = 1;
delay(3000);
} while(IN != 1)
{ OUT = 0;
delay(3000);
} }
} void delay(unsigned int count)
{ int i;
for(i=0;i<count;i++);
} />

  • Well, the code is correct if it implements what is written in the specification.
    So without that it is neither correct, nor incorrect.

    #include<reg51.H>
    sbit IN = 0x90;
    sbit OUT = 0xA0;
    void delay(unsigned int);
    void main()
    {
        while(1)
        {
            P1 = 0xFF;
            P2 = 0x00;
            while(IN == 1)
            {
                OUT = 1;
                delay(3000);
            }
            while(IN != 1)
            {
                OUT = 0;
                delay(3000);
            }
        }
    }
    void delay(unsigned int count)
    {   int i;
        for(i=0;i<count;i++);
    }