0
2.9kviews
Write C language program to check bit P1.2. If it is high send 55 H to PO, otherwise send AAH to P2.
1 Answer
written 6.0 years ago by | • modified 5.9 years ago |
The program
#include< reg51.h>
sbit data_bit = p1^2; $\ \ \ \ \ \ \ \ \ \ \ \ $// declaration of single bit of port 1
void main(void)
{
data_bit = 1; $\ \ \ \ \ \ \ \ \ \ \ \ $// set bit P1.7 as an input
while(1)
{
if(data_bit == 1) $\ \ \ \ \ \ \ \ \ \ \ \ $// check P1.7 bit
P0 = 0x55; $\ \ \ \ \ \ \ \ \ \ \ \ $// if 1 then send 55H to port 0
else
P2 = 0xAA; $\ \ \ \ \ \ \ \ \ \ \ \ $// if 0 then send AAH to port 2
}
}