这是一个基于51hei-5型开发板的原程序~~~ #include<reg52.h>
#include"51hei.h"
#define uchar unsigned char
#define ui unsigned int
sbit D1=P2^1;
sbit SJ=P1^4;
sbit D2=P0^1;
sbit D3=P0^6;
sbit wes=P2^7;
sbit dus=P2^6;
sbit X1=P3^2;
unsigned int a,b,c,d,y,a2,a1,a0, HuanChong;
uchar code table[]={
0x3f,0x06,0x5b,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
void delay_ (unsigned int ms) ;
void display(ui bi,ui si,ui ge)
{uchar i;
P0=table[bi];
dus=1;
dus=0;
P0=0xdf;
wes=1;
wes=0;
delay_(1);
P0=0xff;
wes=1;
wes=0;
for(i=50;i>0;i--);
P0=table[si];
dus=1;
dus=0;
P0=0xbf;
wes=1;
wes=0;
delay_(1);
P0=0xff;
wes=1;
wes=0;
for(i=50;i>0;i--);
P0=table[ge];
dus=1;
dus=0;
P0=0x7f;
wes=1;
wes=0;
delay_(1);
P0=0xff;
wes=1;
wes=0;
for(i=50;i>0;i--);
}
void main()
{
guandz();
if(X1==0){
delay_(1);
if(X1==0){
wes=1;
P0=0xff;
wes=0;
SJ=0;
y=120;
delay_(1);
do{
D1=0;
D2=0;
D3=1;
delay_ (100000);
D1=1;
D2=1;
D3=0;
delay_ (2000);
HuanChong=y;
a2=HuanChong/100;
a1=HuanChong%100/10;
a0=HuanChong%100%10;
display(a2,a1,a0);
}
while(y--);
} }}
void delay_ (unsigned int ms)
{
unsigned char x;
while(ms--)
for(x=0;x<120;x++);
}
求改进 ~ 我想让数码管显示到下一次改变的数的时候
|