0
1.9kviews
Draw the interfacing of relay with 89C51 microcontroller. Write C language program to make relay ON/OFF after certain delay.
1 Answer
0
27views

enter image description here

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++);  
}
Please log in to add an answer.