8051 Microcontroller Hardware Issue

I design a project using an 8051 microcontroller. A project description is mentioned below:

I used two LEDs with the logic that if led1 is on continuously then led2 will be on for 1 sec and off for a long delay. This logic is running fine in proteus software but it is not working when the hardware is designed.

This is my code, if anyone finds any error in the code kindly help me.

#include<stdio.h>
#include<reg51.h>
sbit led1=P1^0; //led1 pin declared
sbit led2=P2^1;

void period(void); // Function prototype declaration
void Delay(void); // Function prototype declaration

void main()
{
led1=0x00;
led2=0xFF;

if(led1==1){ //led status check
led2=0;
period();
led2=1;
Delay();
}
else
led2=1;
}

void period(void)
{
int l;
int m;
for(l=0;l<10;l++)
{
for(m=0;m<10005;m++)
{
}
}
}

void Delay(void)
{
int i;
int j;
for(i=0;i<10;i++)
{
for(j=0;j<100000;j++)
{
}
}
}

Can anyone guide me on this?

Thanks in advance.
 
Top