0
2.1kviews
Write C language program to read P1 and store the ones complement of P1 to P2
1 Answer
1
205views

The program

#include< regx51.h>  
void main(void)  
{  
    unsigned char a,b,c;  
    P1=0xFFH; //set port 0 as an input port   
    P2=0x00FH; //set port 1 as an output port   
    a=P1; //read number from port 1  
    a=~a; //logical not operator  
    P2=a; //store one’s complement to port 2  
}
Please log in to add an answer.