51单片机的0-6的数码管显示
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include<reg52.h>
sbit dula=P2^6;
sbit wela=P2^7;
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,};
uchar aa=0;
void main()
{uint i=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
wela=1;
TL0=(65536-50000)%256;
aa++;
}
P0=0xc0;
wela=0;
dula=1;
P0=table[0];
dula=0;
while(1)
{
if(aa==20)
{
aa=0;
if(i>15)
i=0;
dulaBaidu Nhomakorabea1;
P0=table[i++];
dula=0;
}
}
}
void time0() interrupt 1
{
TH0=(65536-50000)/256;
sbit dula=P2^6;
sbit wela=P2^7;
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,};
uchar aa=0;
void main()
{uint i=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
wela=1;
TL0=(65536-50000)%256;
aa++;
}
P0=0xc0;
wela=0;
dula=1;
P0=table[0];
dula=0;
while(1)
{
if(aa==20)
{
aa=0;
if(i>15)
i=0;
dulaBaidu Nhomakorabea1;
P0=table[i++];
dula=0;
}
}
}
void time0() interrupt 1
{
TH0=(65536-50000)/256;