C51 two-digit digital tube display program design

Publisher:ByteChaserLatest update time:2015-09-10 Source: eefocusKeywords:C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#define uint unsigned int 
#define uchar unsigned char 
sbit k1=P2^0;
sbit k2=P2^1;
uint code table[]={0X00,0X80,0X10,0X90,0X20,0XA0,0X30,0XB0,0X40,0XC0 };
void delay(uint z)
{
uint a,b;
for(a=z;a>0;a--)
{
for(b=z;b>0;b--);
}
}
void main()
{
int c=99,t,shi,ge;
for(t=99;t>0;t--)
{
shi=c/10;
ge=c;
k1=0,k2=1;
P1=table[shi ];
delay(300);
P1=0XFF;

k2=0,k1=1;
P1=table[ge];
delay(200);
P1=0XFF;
k1=0,k2=0;
c--;
if(c ==0)
c=99;


}
}

answer:

It must be different at the same time, because you showed it as ten and then one.

In fact, the so-called simultaneous display means that if the cycle scanning time interval is short, it will naturally appear to be simultaneous.

What you have to do is to display the tens digit and then the ones digit while displaying the delay , instead of displaying one and then the other.

The best way is to put it in the interrupt to ensure the display effect.

bit flag;

int shi ,ge;

These three are external variables  and it should be OK to call this function during the delay process.

void shown()

{

if (flag==0)

{

P1=table[shi];k2=1,k1=0;

}

else

{

P1=table[ge];k2=0,k1=1;

}

flag=~flag;

}

Keywords:C51 Reference address:C51 two-digit digital tube display program design

Previous article:C51 MCU data type range
Next article:C51 MCU delay program source code

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号