数码管显示数字 甲机 乙级
#include <reg51.h>
unsigned char temp,num;
void main(){
EX0=1;
IT0=1;
IT1=1;
EX1=1;
EA=1;
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
SCON=0x50;
TR1=1;
while(1){
}
}
void reset() interrupt 2{
EX0=1;
SBUF=0x0a;
while(TI==0);TI=0;
}
void send() interrupt 0{
EX0=0;
temp=P1;
switch(temp){
case 0x7f: num=0x08;break;//0111 1111
case 0xbf: num=0x07;break;//1011 1111
case 0xdf: num=0x06;break;//1101 1111
case 0xef: num=0x05;break;//1110 1111
case 0xf7: num=0x04;break;//1111 0111
case 0xfb: num=0x03;break;
case 0xfd: num=0x02;break;
case 0xfe: num=0x01;break;
}
SBUF=num;
while(TI==0);TI=0;
}
4、
#include <reg51.h>
unsigned char temp=0;
void main(){
EA=1;
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
SCON=0x50;
TR1=1;
P2=0x0a;
while(1){
while(RI==0);
RI=0;
P2=SBUF;
}
}