0
2.0kviews
Draw the interfacing of key and LED to 89C51 microcontroller pins P1.0 and P2.0 respectively.

Write C language program to read the status of key and display it on LED. (Key open = LED OFF and key closed = LED ON)


1 Answer
0
54views

enter image description here

Program

 #include< reg51.h>    
sbit=sw P1^3; //make P1.3 as input   
sbit led=P3^5; //make P3.5 as output  
void main (void)   
{ 
    sw=1;  
    led=0;  
    while(1) //repeat loop  
    {  
        if(sw==0) //if switch is closed on the led else off the led  
        led=1;  
        else  
        led=0;   
    } //end of while  
} //end of main
Please log in to add an answer.