📄 cs16-2.c
字号:
#include <REG51.H>
#define uint unsigned int
#define uchar unsigned char
uchar code SEG7[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code ACT[4]={0xfe,0xfd,0xfb,0xf7};
uint counter;
/****************************/
void initial(void)
{
TMOD=0x50;
TH1=0x00;
TL1=0x00;
IE=0x00;
TR1=1;
}
/******************************/
void delay(uint k)
{
uint data i,j;
for(i=0;i<k;i++)
{for(j=0;j<121;j++)
{;}}
}
/**********************************/
void display(void)
{
P0=SEG7[counter%10];P2= ACT[0];delay(1);
P0=SEG7[(counter%100)/10];P2= ACT[1];delay(1);
P0=SEG7[(counter/100)%10];P2= ACT[2];delay(1);
P0=SEG7[counter/1000];P2= ACT[3];delay(1);
}
/*********************************/
void main(void)
{ uint temp1,temp2;
initial();
for(;;)
{
display();
temp1=TL1;temp2=TH1;
counter=(temp2<<8)+temp1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -