0
1.7kviews
Draw the interfacing of relay with 89C51 microcontroller. Write C language program to make relay ON/OFF after certain delay.
1 Answer
written 5.7 years ago by | • modified 5.6 years ago |
Program
#include < reg51.h>
sbit relay =P2 0;
void ms_delay (unsigned int); //delay function
void main(void)
{
P2=0; //initialize port
while(1) //loop forever
{
relay=1; //relay is on
ms_delay(200); //delay
relay=0; //relay is off
ms_delay(200); //delay
}
}
void ms_delay (unsigned int itime)
{
unsigned int x,y;
for(x=0; x< itime; x++)
for (y=0; y<1275; y++);
}