单片机proteus 仿真,怎么数码管显示不出来呢
#include<reg52.h>#defineuintunsignedint#defineucharunsignedcharvoiddisplay(uchar,ucha...
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
void display(uchar, uchar, uchar);
void delay(uint);
sbit dula = P2^6;
sbit wela = P2^7;
uchar bai = 0,shi = 0, ge = 0;
uchar code smg[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void main()
{
uchar number = 223;
bai = number/100;
shi = number%100/10;
ge = number%10;
while(1)
{
display(bai, shi, ge);
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar bai, uchar shi, uchar ge)
{
dula = 1;
P0 = smg[ge];
dula = 0;
wela = 1;
P0 = 0xfb;
wela = 0;
delay(5);
dula = 1;
P0 = smg[shi];
dula = 0;
wela = 1;
P0 = 0xfd;
wela = 0;
delay(5);
dula = 1;
P0 = smg[bai];
dula = 0;
wela = 1;
P0 = 0xfe;
wela = 0;
delay(5);
}
好像加不进去啊 展开
#define uint unsigned int
#define uchar unsigned char
void display(uchar, uchar, uchar);
void delay(uint);
sbit dula = P2^6;
sbit wela = P2^7;
uchar bai = 0,shi = 0, ge = 0;
uchar code smg[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void main()
{
uchar number = 223;
bai = number/100;
shi = number%100/10;
ge = number%10;
while(1)
{
display(bai, shi, ge);
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar bai, uchar shi, uchar ge)
{
dula = 1;
P0 = smg[ge];
dula = 0;
wela = 1;
P0 = 0xfb;
wela = 0;
delay(5);
dula = 1;
P0 = smg[shi];
dula = 0;
wela = 1;
P0 = 0xfd;
wela = 0;
delay(5);
dula = 1;
P0 = smg[bai];
dula = 0;
wela = 1;
P0 = 0xfe;
wela = 0;
delay(5);
}
好像加不进去啊 展开
展开全部
void display(uchar bai, uchar shi, uchar ge)
{
dula = 1;
P0 = smg[ge];
dula = 0;
wela = 1;
P0 = 0xfb;
wela = 0;
delay(5);
P0=0x00; //消隐
dula = 1;
P0 = smg[shi];
dula = 0;
wela = 1;
P0 = 0xfd;
wela = 0;
delay(5);
P0=0x00; //消隐
dula = 1;
P0 = smg[bai];
dula = 0;
wela = 1;
P0 = 0xfe;
wela = 0;
delay(5);
P0=0x00; //消隐
}
展开全部
程序似乎没错,看看硬件吧。数码管共阴共阳是否接错!
追问
没接错啊,数码管就只有三段亮,一个数一段,但是如果把延迟调长一点 会显示出来但是会闪,那样没有同时显示的“错觉”。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不知,你这个线路是怎么接的呢?有图纸吗,也许你的电路有问题的
追问
好像加不进图片啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询