多路開關(guān)狀態(tài)指示器設(shè)計(jì)
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
9.方法二(C語(yǔ)言源程序)
#include AT89X51.H>
void main(void)
{
while(1)
{
if(P1_4==0)
{
P1_0=0;
}
else
{
P1_0=1;
}
if(P1_5==0)
{
P1_1=0;
}
else
{
P1_1=1;
}
if(P1_6==0)
{
P1_2=0;
}
else
{
P1_2=1;
}
if(P1_7==0)
{
P1_3=0;
}
else
{
P1_3=1;
}
}
}
多路開關(guān)狀態(tài)指示器設(shè)計(jì)全部代碼結(jié)束
評(píng)論