怎么让单片机的8个数码管同时显示不同的数字 10
展开全部
动态扫瞄或者静态显示。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,aa,numdu,numwe;
sbit dula=P2^5;
sbit wela=P2^6;
sbit wr=P2^7;
uchar code table[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x80};
uchar code tablewe[]={
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void main()
{
numdu=0;
numwe=0;
aa=0;
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(aa==100)
{
aa=0;
numdu++;
if(numdu==9)
numdu=1;
P0=table[numdu];
dula=0;
wr=0;
wr=1;
dula=1;
P0=tablewe[numwe];
wela=0;
wr=0;
wr=1;
wela=1;
numwe++;
if(numwe==8 )
numwe=0;
}
}
}
void timer0() interrupt 1
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
aa++;
}
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,aa,numdu,numwe;
sbit dula=P2^5;
sbit wela=P2^6;
sbit wr=P2^7;
uchar code table[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x80};
uchar code tablewe[]={
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void main()
{
numdu=0;
numwe=0;
aa=0;
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(aa==100)
{
aa=0;
numdu++;
if(numdu==9)
numdu=1;
P0=table[numdu];
dula=0;
wr=0;
wr=1;
dula=1;
P0=tablewe[numwe];
wela=0;
wr=0;
wr=1;
wela=1;
numwe++;
if(numwe==8 )
numwe=0;
}
}
}
void timer0() interrupt 1
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
aa++;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询