proteus仿真LED数码管不显示
#include<reg51.h>unsignedchara[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f...
#include<reg51.h>
unsigned char a[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,},b[4],c=0x01;
sbit START=P2^4;
sbit OE=P2^6;
sbit EOC=P2^5;
sbit add_a=P2^2;
sbit add_b=P2^1;
sbit add_c=P2^0;
sbit led=P2^7;
void Delay1ms(unsigned int count);
{ unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}
void show()
{
unsigned int r;
for(r=0;r<4;r++)
{
P1=(c<<r);
P3=b[r];
if(r==2)
P3=P3|0x80;
Delay1ms(1);
}
}
void main(void)
{
unsigned int addata=0,i;
while(1)
{
add_a=0; add_b=0;add_c=0;
START=1;
START=0;
while(EOC==0)
{
OE=1;
}
addata=P0;//读AD转换数据
if(addata>=0x40)
for(i=0;i<=100;i++)
{
led=~led;
}
led=1;
}
else
{
led=0;
}
addata=addata*1.96;
OE=0;
b[0]=a[addata%10];
b[1]=a[addata/10%10];
b[2]=a[addata/100%10];
b[3]=a[addata/1000];
for(i=0;i<=200;i++)
{
show();
}
add_a=1;
add_b=0;
add_c=0;
START=1;
START=0;
while(EOC==0)
{
OE=1;
}
addata=P0;
if(addata>=0x80)
{
for(i=0;i<=100;i++)
{
led=~led;
}
led=1;
}
else
{
led=0;
}
addata=addata*1.96;
OE=0;
b[0]=a[addata%10];
b[1]=a[addata/10%10];
b[2]=a[addata/100%10];
b[3]=1;
for(i=0;i<=200;i++)
{
show();
}
}
} 展开
unsigned char a[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,},b[4],c=0x01;
sbit START=P2^4;
sbit OE=P2^6;
sbit EOC=P2^5;
sbit add_a=P2^2;
sbit add_b=P2^1;
sbit add_c=P2^0;
sbit led=P2^7;
void Delay1ms(unsigned int count);
{ unsigned int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++);
}
void show()
{
unsigned int r;
for(r=0;r<4;r++)
{
P1=(c<<r);
P3=b[r];
if(r==2)
P3=P3|0x80;
Delay1ms(1);
}
}
void main(void)
{
unsigned int addata=0,i;
while(1)
{
add_a=0; add_b=0;add_c=0;
START=1;
START=0;
while(EOC==0)
{
OE=1;
}
addata=P0;//读AD转换数据
if(addata>=0x40)
for(i=0;i<=100;i++)
{
led=~led;
}
led=1;
}
else
{
led=0;
}
addata=addata*1.96;
OE=0;
b[0]=a[addata%10];
b[1]=a[addata/10%10];
b[2]=a[addata/100%10];
b[3]=a[addata/1000];
for(i=0;i<=200;i++)
{
show();
}
add_a=1;
add_b=0;
add_c=0;
START=1;
START=0;
while(EOC==0)
{
OE=1;
}
addata=P0;
if(addata>=0x80)
{
for(i=0;i<=100;i++)
{
led=~led;
}
led=1;
}
else
{
led=0;
}
addata=addata*1.96;
OE=0;
b[0]=a[addata%10];
b[1]=a[addata/10%10];
b[2]=a[addata/100%10];
b[3]=1;
for(i=0;i<=200;i++)
{
show();
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询