用AT89S51單片機(jī)多路開(kāi)關(guān)狀態(tài)指示
6. 方法一(匯編源程序)
ORG 00H
START: MOV A,P1
ANL A,#0F0H
RR A
RR A
RR A
RR A
XOR A,#0F0H
MOV P1,A
SJMP START
END
7. 方法一(C語(yǔ)言源程序)
#include AT89X51.H>
unsigned char temp;
void main(void)
{
while(1)
{
temp=P1>>4;
temp=temp | 0xf0;
P1=temp;
}
}
8. 方法二(匯編源程序)
ORG 00H
START: JB P1.4,NEXT1
CLR P1.0
SJMP NEX1
NEXT1: SETB P1.0
NEX1: JB P1.5,NEXT2
CLR P1.1
SJMP NEX2
NEXT2: SETB P1.1
NEX2: JB P1.6,NEXT3
CLR P1.2
SJMP NEX3
NEXT3: SETB P1.2
NEX3: JB P1.7,NEXT4
CLR P1.3
SJMP NEX4
NEXT4: SETB P1.3
NEX4: SJMP START
END
評(píng)論