aliraza786
Full Member level 4
- Joined
- Nov 10, 2009
- Messages
- 210
- Helped
- 14
- Reputation
- 28
- Reaction score
- 14
- Trophy points
- 1,298
- Location
- Lahore, Pakistan, Pakistan
- Activity points
- 2,914
hello ...i need some help in gnerating time delay of exact 5 second
does this code is corect..?? but in simulation and in hardware it does not work ...
_______________________________________________________________________
#include<reg51.h>
unsigned char Ali[9]={0,1,2,4,8,16,32,64,128};
sbit led=P1^1; unsigned char k,i;
void delay()
{
TMOD=0x02;
TL0=0x67;
TH0=0xFC;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
void main()
{
led=0;
for(i=0;i<5000;i++)
{ delay(); }
led=1;
for(k=0;k<5000;k++)
{ delay(); }
}
main while loop is missing in this code but after ading the main while loop problem is not solved....!!!
does this code is corect..?? but in simulation and in hardware it does not work ...
_______________________________________________________________________
#include<reg51.h>
unsigned char Ali[9]={0,1,2,4,8,16,32,64,128};
sbit led=P1^1; unsigned char k,i;
void delay()
{
TMOD=0x02;
TL0=0x67;
TH0=0xFC;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
void main()
{
led=0;
for(i=0;i<5000;i++)
{ delay(); }
led=1;
for(k=0;k<5000;k++)
{ delay(); }
}
main while loop is missing in this code but after ading the main while loop problem is not solved....!!!
Last edited: