0
9.3kviews
Write 89C51 C language program to toggle all bits of port P2 continuously with 500 ms delay.
1 Answer
written 6.0 years ago by | • modified 6.0 years ago |
The program
#include <reg51.h>
void delay (unsigned int);
void main (void)
{
while(1) //repeat loop
{
P2=0xff; //toggle all bits of port2
delay (500); //add delay
P2=0x00; //toggle all bits of port2
delay (500); //add delay
}
}
void delay (unsigned int i)
{
unsigned int x, y;
for(x=0; x< i; x++)
for (y=0; y<1275; y++);
}