找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

请帮帮看看我的跑表程序为什么在按下键时不能显示该时间

[复制链接]
admin 发表于 2012-9-2 18:35:03 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar count;
uint disnum;
sbit dula=P2^6;
sbit wela=P2^7;
sbit key1=P3^4;
uchar code tableshige[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,
0x7d,0x07,0x7f,0x6f,0x77};
uchar code tablebai[]={
0xbf,0x86,0xdb,0xcf,0xe6,0xed,
0xfd,0x87,0xff,0xef,0xf7};
void display(uchar,uchar,uchar);
void delay(uchar);
void main()
{
EA=1;
ET1=1;
TMOD=0x10;
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
TR1=1;
while(1)
{
if(count==1)
{
count=0;
if(disnum==1000)
disnum=0;
disnum++;
if(key1==0)
{
delay(5);
if(key1==0)
TR1=0;
while(!key1);
display(disnum/100,disnum%100/10,disnum%10);
delay(5);
while(!key1);
TR1=1;
}
}
display(disnum/100,disnum%100/10,disnum%10);
}
}
void time1() interrupt 3
{
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
count++;
}
void display(uchar bai,uchar shi, uchar ge)
{
P0=0xff;
wela=1;
wela=0;
P0=tablebai[bai];
dula=1;
dula=0;
P0=0xfe;
wela=1;
wela=0;
delay(1);

P0=0xff;
wela=1;
wela=0;
P0=tableshige[shi];
dula=1;
dula=0;
P0=0xfd;
wela=1;
wela=0;
delay(1);

P0=0xff;
wela=1;
wela=0;
P0=tableshige[ge];
dula=1;
dula=0;
P0=0xfb;
wela=1;
wela=0;
delay(1);
}
void delay(uchar x)
{
uchar a,b;
for(a=x;a>0;a--)
for(b=100;b>0;b--);
}
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-29 04:54 , Processed in 0.049675 second(s), 9 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表