一、计数器的原理和应用
要求:每计数三次,数码管值加一
#include<reg51.h>
unsigned char s[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char num=0;
void initcounter()
{
TMOD=0x06;//0000 0110
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++;
}
标签:void,unsigned,char,计数器,num,应用,原理,256,0x06 From: https://blog.csdn.net/weixin_62428401/article/details/137154289