?? frequency.txt
字號:
#include<reg51.h>
sbit p10=P1^0;
sbit p11=P1^1;
sbit p12=P1^2;
sbit p13=P1^3;
sbit p14=P1^4;
sbit p15=P1^5;
unsigned char cnt=20;
unsigned int count;
unsigned char shiwan;
unsigned char wan;
unsigned char qian;
unsigned char bai;
unsigned char shi;
unsigned char ge;
unsigned char wu;
unsigned char table[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x60//0,1,2,3,4,5,6,7,8,9,-
};
void delay(unsigned int i)
{
while(i--);
}
void display()
{
P1=0xfe;
P0=table[ge];
delay(300);//顯示第1個數碼管
P1=0xfd;
P0=table[shi];
delay(300);//顯示第2個數碼管
P1=0xfb;
P0=table[bai];
delay(300);//顯示第3個數碼管
P1=0xf7;
P0=table[qian];
delay(300);//顯示第4個數碼管
P1=0xef;
P0=table[wan];
delay(300);//顯示第5個數碼管
P1=0xdf;
P0=table[shiwan];
delay(300);//顯示第6個數碼管
/*if(count>100000)
{
P1=0x60;
P0=table[wu];
delay(300);
}*/
}
void init()
{
TMOD=0x59;//0101 1001,T1計數,T0定時
TH0=0x3c;
TL0=0xb0;
TH1=0xEC;//T1計數器溢出初值
TL1=0x78;
IE=0x82;
TR0=1;
TR1=1;
}
void main()
{
init();
P1=0xff;
P0=0;//初始化顯示
while(1)
{
display();
}
}
void T0_int() interrupt 1
{
cnt--;
TH0=0x3c;
TL0=0xb0;
if(cnt==0)
{
count=TH1*256+TL1;
shiwan=count/100000;
wan=(count-shiwan*100000)/10000;
qian=(count-shiwan*100000-wan*10000)/1000;
bai=(count-shiwan*100000-wan*10000-qian*1000)/100;
shi=(count-shiwan*100000-wan*10000-qian*1000-bai*100)/10;
ge=count-shiwan*100000-wan*10000-qian*1000-bai*100-shi*10;
//wu=0x60;
TH1=0;
TL1=0;
cnt=20; //定時20次
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -