只有本站会员才能查看附件,请 登录
程序代码:
#include <REGX51.H>
#include <intrins.h>
void delay(unsigned char _ms) //@11.0592MHz
{
unsigned char i, j;
while(_ms--)
{
_nop_();
i = 2;
j = 199;
do
{
while (--j);
} while (--i);
}
} %单位延时
sbit wei=P2^7;
sbit dua=P2^6;
unsigned char i=0;
unsigned int code a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void main()
{
EA=1;%打开总开关
EX0=1;%打开外部中断0
IT0=1;%下降沿触发
while(1){
P0=0xfe;
wei=0;%选择第一个数码管
wei=1;%关闭位选
dua=1;%打开段选
P0=a[i];%数码管显示的值
}
}
void xint0() interrupt 0 using 1 %中断函数
{
i=i+1;
if(i==15)
i=0;
}
#include <intrins.h>
void delay(unsigned char _ms) //@11.0592MHz
{
unsigned char i, j;
while(_ms--)
{
_nop_();
i = 2;
j = 199;
do
{
while (--j);
} while (--i);
}
} %单位延时
sbit wei=P2^7;
sbit dua=P2^6;
unsigned char i=0;
unsigned int code a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void main()
{
EA=1;%打开总开关
EX0=1;%打开外部中断0
IT0=1;%下降沿触发
while(1){
P0=0xfe;
wei=0;%选择第一个数码管
wei=1;%关闭位选
dua=1;%打开段选
P0=a[i];%数码管显示的值
}
}
void xint0() interrupt 0 using 1 %中断函数
{
i=i+1;
if(i==15)
i=0;
}