用动态扫描方法和定时器1在数码管的前三位显示出秒表,精确到1%秒,即后两位显示1%秒,一直循环下去?
好酷屋教程网小编为您收集和整理了用动态扫描方法和定时器1在数码管的前三位显示出秒表,精确到1%秒,即后两位显示1%秒,一直循环下去?的相关教程://用动态扫描方法和定时器1在数码管的前三位显示出秒表,精确到1%秒,即后两位显示1%秒,一直循环下去。#include#defineuintunsignedint#defineucharunsign
//用动态扫描方法和定时器1在数码管的前三位显示出秒表,精确到1%秒,即后两位显示1%秒,一直循环下去。
#include
#define uint unsigned int
#define uchar unsigned char
sbit wela=P2^7;
sbit dula=P2^6;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void init();
void display(uchar fen,miao1,miao2);
void delay(uchar);
uchar tt,fen,miao1,miao2;
uint temp;
void main()
{
init();
while(1)
{
if(tt==70)
{
tt=0;
temp++;
if(temp==600)
temp=0;
fen=temp/100;
miao1=temp%100/10;
miao2=temp%10;
}
display(fen,miao1,miao2);
}
}
void display(uchar fen,miao1,miao2)
{
dula = 1;
P0 = table[fen];
dula = 0;
P0 = 0xff;
wela = 1;
P0 = 0xfe;
wela = 0;
delay(1);
dula = 1;
P0 = table[miao1];
dula = 0;
P0 = 0xff;
wela = 1;
P0 = 0xfd;
wela = 0;
delay(1);
dula = 1;
P0 = table[miao2];
dula = 0;
P0 = 0xff;
wela = 1;
P0 = 0xfb;
wela = 0;
delay(1);
}
void delay(uchar z)
{
uchar x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void init()
{
temp=0;
TMOD=0x01;
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
EA=1;
ET1=1;
TR1=1;
}
void timer1() interrupt 3
{
TH1=(65536-10000)/256;
TL1=(65536-10000)%256;
tt++;
}
以上就是好酷屋教程网小编为您收集和整理的显示,秒表,数码管相关内容,如果对您有帮助,请帮忙分享这篇文章^_^
本文来源: https://www.haoku5.com/youxi/66d68678b837627916088323.html
相关推荐