六位数码
时间:10-02
整理:3721RD
点击:
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar seg[10]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
uchar shu[6]={0};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
void disp(uint x)
{
uint i,t=0x01;
shu[0]=x/100000;
shu[1]=x%100000/10000;
shu[2]=x%10000/1000;
shu[3]=x%1000/100;
shu[4]=x%100/10;
shu[5]=x%10;
for(i=0;i<6;i++)
{
P2=t;
P0=seg[shu[i]];
delay(5);
t=t<<1;
}
}
void main()
{
uint x,y;
while(1)
{
for(x=11111;x<65537;x++)
{
for(y=0;y<5;y++)
disp(x);
}
}
}
#define uchar unsigned char
#define uint unsigned int
uchar seg[10]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
uchar shu[6]={0};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
void disp(uint x)
{
uint i,t=0x01;
shu[0]=x/100000;
shu[1]=x%100000/10000;
shu[2]=x%10000/1000;
shu[3]=x%1000/100;
shu[4]=x%100/10;
shu[5]=x%10;
for(i=0;i<6;i++)
{
P2=t;
P0=seg[shu[i]];
delay(5);
t=t<<1;
}
}
void main()
{
uint x,y;
while(1)
{
for(x=11111;x<65537;x++)
{
for(y=0;y<5;y++)
disp(x);
}
}
}
才五位数呀
