欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
基于51單片機(jī)的噪聲計設(shè)計
[打印本頁]
作者:
subobo
時間:
2018-7-7 12:53
標(biāo)題:
基于51單片機(jī)的噪聲計設(shè)計
#include <reg52.h>
#include "LCD1602.h"
unsigned char welcome[]={"welcome!"};
unsigned char Show0[6]={"Noise:"};
unsigned char Show1[5]={"dB"};
/*unsigned int code Countnum[60]={ 11, 13, 15, 17, 19, 22, 24, 27, 31, 34, //T0計數(shù)值
39, 44, 49, 55, 62, 69, 78, 87, 98, 110,
123, 138, 155, 174, 195, 219, 246, 276, 309, 347,
390, 438, 491, 550, 618, 693, 778, 873, 979, 1099,
1233,1383,1552,1742,1954,2193,2460,2760,3097,3475,
3899,4375,4909,5508,6180,6934,7780,8729,9794,10989,};*/
unsigned long code Countnum[100]={10,11,12,13,15,17,19,22,25,28,
31,35,39,43,48,54,60,67,75,84,
94,105,117,131,146,163,182,204,228,255,
286,320,359,402,451,506,567,636,713,799,
896,1005,1127,1264,1418,1590,1783,2000,2244,2517,
2824,3168,3556,3989,4475,5020,5632,6319,7089,7953,
8923,10011,11232,12602,14139,15863,17798,19969,22405,25138,
28204,31644,35504,39835,44694,50146,56263,63127,70828,79469,
89164,100042,112247,125941,141305,158544,177886,199588,223937,251257,
281910,316303,354891,398187,446765,501270,562424,631039,708025,794404,};
unsigned char code dB[100][3]={"031","032","033","034","035","036","037","038","039","040", //T0計數(shù)值對應(yīng) dB
"041","042","043","044","045","046","047","048","049","050",
"051","052","053","054","055","056","057","058","059","060",
"061","062","063","064","065","066","067","068","069","070",
"071","072","073","074","075","076","077","078","079","080",
"081","082","083","084","085","086","087","088","089","090",
"091","092","093","094","095","096","097","098","099","100",
"101","102","103","104","105","106","107","108","109","110",
"111","112","113","114","115","116","117","118","119","120",
"121","122","123","124","125","126","127","128","129","130",
};
sbit beep=P2^2;
sbit key_1=P2^1;
sbit key_2=P2^0;
//////////////////////////////////////////////////////全局變量/////////////////////////////////////////////////////
unsigned long count,c;
uchar t,z;
uchar shu,ys;
//////////////////////////////////////////////////////函數(shù)聲明////////////////////////////////////////////////////
/************************************
延時子程序
延時時間(xms*1)ms
*************************************/
void delayms(uint xms) //延時xms
{
uint x,y;
for(x=xms;x>0;x--)
for(y=90;y>0;y--);
}
void key()
{
if (key_1==0)
{
delayms(10);
if (key_1==0)
{
while(key_1==0);
if (shu<99) shu++;
}
}
if (key_2==0)
{
delayms(10);
if (key_2==0)
{
while(key_2==0);
if (shu>0) shu--;
}
}
}
void alarm()
{
ys++;
if (ys>20)
{
ys=0;
beep=!beep;
}
}
//////////////////////////////////////////主函數(shù)///////////////////////////////////////////////////////////
void main(void)
{
uint m,n;
uint i;
delayms(1000);
TMOD=0X15; //T0外部計數(shù) 工作方式1 T1定時方式1
EA=0; //開總中斷
ET1=0; //關(guān)閉T1
TH0=0;
TL0=0;
TH1=(65536-50000)/256; //裝初值
TL1=(65536-50000)%256; //裝初值
init_1602();
WRITE_LCD1602_COM(0x80+3); // 顯示地址
for(i=0; i<6; i++)
{
WRITE_LCD1602_DAT(Show0[i]);
delayms(5);
}
WRITE_LCD1602_COM(0x80+12); // 顯示地址
for(i=0;i<2;i++)
{
WRITE_LCD1602_DAT(Show1[i]);
delayms(5);
}
WRITE_LCD1602_COM(0xc0+3); // 顯示地址
WRITE_LCD1602_byte("Limit:");
WRITE_LCD1602_COM(0xc0+12); // 顯示地址
for(i=0;i<2;i++)
{
WRITE_LCD1602_DAT(Show1[i]);
delayms(5);
}
EA=1;
ET1=1; //開T1
TR1=1; //T1開始定時
TR0=1; //T0開始計數(shù)
while(1)
{
key();
WRITE_LCD1602_COM(0xc0+9);
WRITE_LCD1602_DAT(0x30+(shu+31)/100%10);
WRITE_LCD1602_DAT(0x30+(shu+31)/10%10);
WRITE_LCD1602_DAT(0x30+(shu+31)%10);
i=0;
if(count==0)
continue;
while(count>Countnum[i])
{
i++;
}
m=i;
i=0;
WRITE_LCD1602_COM(0x80+9);
for(n=0; n<3; n++)
{
WRITE_LCD1602_DAT(dB[m][n]);
delayms(5);
}
WRITE_LCD1602_COM(0xc0+9);
WRITE_LCD1602_DAT(0x30+(shu+31)/100%10);
WRITE_LCD1602_DAT(0x30+(shu+31)/10%10);
WRITE_LCD1602_DAT(0x30+(shu+31)%10);
if(m>=shu)
{
alarm();
}else
{
beep=1;
}
}
}
void Timer0() interrupt 1
{
z++;
}
void Timer1() interrupt 3
{
TR1=0; //關(guān)閉T1定時
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t++;
if(t==20) //定時1s時間到
{
t=0;
TR0=0; //T0停止計數(shù)
c=z*65535+(TH0*256+TL0); // 將計數(shù)值讀取
TH0=0; //清空計數(shù)值
TL0=0; //清空計數(shù)值
TR0=1; //T0開始計數(shù)
count=c;
c=0;
z=0;
}
TR1=1; //T1開始定時
}
TIM截圖20180707125152.png
(33.09 KB, 下載次數(shù): 51)
下載附件
2018-7-7 12:52 上傳
作者:
admin
時間:
2018-7-8 01:33
本帖需要補(bǔ)全頭文件后才可獲得積分
作者:
yiyiyaya@nimen
時間:
2019-4-16 16:45
樓主你好
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1