跪求,51单片机的LED动态显示 程序 ,急啊。。。
发布网友
发布时间:2022-05-07 00:33
我来回答
共1个回答
热心网友
时间:2023-10-09 15:06
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
sbit la=P1;
sbit wela=P2;
uchar ,shi,ge;
uint tt;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void display(uchar,uchar,uchar);
void delay(uint z)
{
uint i,j;
for(j=z;j>0;j--)
for(i=0;i<110;i++);
}
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
display(,shi,ge);
}
}
void display(uchar a,uchar b,uchar c)
{
la=1;
P1=table[a];
la=0;
P1=0xff;
wela=1;
P2=0xfe;
wela=0;
delay(5);
la=1;
P1=table[b];
la=0;
P1=0xff;
wela=1;
P2=0xfd;
wela=0;
delay(5);
la=1;
P1=table[c];
la=0;
P1=0xff;
wela=1;
P2=0xfb;
wela=0;
delay(5);
}
void timer() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++;
if(tt==1000)
tt=0;
=tt/100;
shi=tt%100/10;
ge=tt%10;
}