#include"reg51.h"
unsigned char num=0,count=0;
unsigned char s[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0xff,0x6f};//共阴极0-9
void initcounter()
{
TMOD=0x06;
TH0=256-3;
TL0=256-3;
ET0=1;
EA=1;
TR0=1;
}
void display()
{
P2=s[num];
if(num==10)
{
num=0;
}
}
void main()
{
initcounter();
while(1)
{
display();
}
}
void counter_isr()interrupt 1
{
num++;
}
计数器keil代码
最新推荐文章于 2023-03-24 13:01:07 发布