0
2.8kviews
Write C language program to read P0 and P1. Add the content of P0 and P1 and store the result to P2.
1 Answer
written 6.0 years ago by | • modified 5.9 years ago |
The program
#include < reg51.h>
void main(void)
{
unsigned char a,b,c;
P0=0xFFH; //set port 0 as an input port
P1=0xFFH; //set port 1 as an input port
a=P0; //read number from port 0
b=P1; //read second number from port 1
c=a+b; //add both numbers
P2=c; //send result to port 2
}