<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 自制帶有開機(jī)音樂的可顯數(shù)字溫度計(jì)

          自制帶有開機(jī)音樂的可顯數(shù)字溫度計(jì)

          作者: 時(shí)間:2012-10-24 來源:網(wǎng)絡(luò) 收藏
          #include REG52.H>#include "SoundPlay.h"#define  uchar  unsigned  char #define  uint   unsigned  intsbit  DATA = P3^7; //DS18B20接入口uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};char  bai,shi,ge; //定義變量/*延時(shí)子函數(shù)*/void delay(uint num){while(num--) ;}void Delay1ms(unsigned int count){unsigned int i,j;for(i=0;icount;i++)for(j=0;j120;j++);}/*************DS18b20溫度傳感器函數(shù)*********************/Init_DS18B20(void)     //傳感器初始化{uchar x=0;DATA = 1;    //DQ復(fù)位delay(10);  //稍做延時(shí)DATA = 0;    //單片機(jī)將DQ拉低delay(80); //精確延時(shí) 大于 480us    //450DATA = 1;    //拉高總線delay(20);x=DATA;      //稍做延時(shí)后 如果x=0則初始化成功 x=1則初始化失敗delay(30);}//讀一個(gè)字節(jié)ReadOneChar(void){uchar i=0;uchar dat = 0;for (i=8;i>0;i--){DATA = 0; // 給脈沖信號(hào)dat>>=1;DATA = 1; // 給脈沖信號(hào)if(DATA)dat|=0x80;delay(8);}return(dat);}//寫一個(gè)字節(jié)WriteOneChar(unsigned char dat){uchar i=0;for (i=8; i>0; i--){DATA = 0;DATA = dat0x01;delay(10);DATA = 1;dat>>=1;}delay(8);}//讀取溫度int ReadTemperature(void){uchar a=0;uchar b=0;int t=0;float tt=0;Init_DS18B20();WriteOneChar(0xCC); // 跳過讀序號(hào)列號(hào)的操作WriteOneChar(0x44); // 啟動(dòng)溫度轉(zhuǎn)換Init_DS18B20();WriteOneChar(0xCC); //跳過讀序號(hào)列號(hào)的操作WriteOneChar(0xBE); //讀取溫度寄存器等(共可讀9個(gè)寄存器) 前兩個(gè)就是溫度a=ReadOneChar();//低位b=ReadOneChar();//高位t=b;t=8;t=t|a;tt=t*0.0625;t= tt*10+0.5; return(t);}/*顯示子函數(shù)*/void  display(int bai,int shi,int ge){P2=0XFB; //顯示小數(shù)點(diǎn)P0=0X80; //顯示小數(shù)點(diǎn)delay(50);//顯示小數(shù)點(diǎn)P2=0xf7;P0=table[bai];//顯示千位delay(50);//一小段延時(shí)動(dòng)態(tài)顯示P2=0xfb;P0=table[shi];//顯示百位delay(50);P2=0xfd;P0=table[ge];//顯示十位delay(100);}//*****************************Music********************************//揮著翅膀的女孩unsigned char code Music_Girl[]={ 0x17,0x02, 0x17,0x03, 0x18,0x03, 0x19,0x02, 0x15,0x03,0x16,0x03, 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x18,0x03,0x19,0x02, 0x16,0x03, 0x17,0x03, 0x18,0x02, 0x18,0x03,0x17,0x03, 0x15,0x02, 0x18,0x03, 0x17,0x03, 0x18,0x02,0x10,0x03, 0x15,0x03, 0x16,0x02, 0x15,0x03, 0x16,0x03,0x17,0x02, 0x17,0x03, 0x18,0x03, 0x19,0x02, 0x1A,0x03,0x1B,0x03, 0x1F,0x03, 0x1F,0x03, 0x17,0x03, 0x18,0x03,0x19,0x02, 0x16,0x03, 0x17,0x03, 0x18,0x03, 0x17,0x03,0x18,0x03, 0x1F,0x03, 0x1F,0x02, 0x16,0x03, 0x17,0x03,0x18,0x03, 0x17,0x03, 0x18,0x03, 0x20,0x03, 0x20,0x02,0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x20,0x03, 0x21,0x03,0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x1F,0x03,0x1B,0x03, 0x19,0x03, 0x19,0x03, 0x15,0x03, 0x1A,0x66,0x1A,0x03, 0x19,0x03, 0x15,0x03, 0x15,0x03, 0x17,0x03,0x16,0x66, 0x17,0x04, 0x18,0x04, 0x18,0x03, 0x19,0x03,0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x20,0x03, 0x21,0x03,0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66, 0x1F,0x03,0x1B,0x03, 0x19,0x03, 0x19,0x03, 0x15,0x03, 0x1A,0x66,0x1A,0x03, 0x19,0x03, 0x19,0x03, 0x1F,0x03, 0x1B,0x03,0x1F,0x00, 0x1A,0x03, 0x1A,0x03, 0x1A,0x03, 0x1B,0x03,0x1B,0x03, 0x1A,0x03, 0x19,0x03, 0x19,0x02, 0x17,0x03,0x15,0x17, 0x15,0x03, 0x16,0x03, 0x17,0x03, 0x18,0x03,0x17,0x04, 0x18,0x0E, 0x18,0x03, 0x17,0x04, 0x18,0x0E,0x18,0x66, 0x17,0x03, 0x18,0x03, 0x17,0x03, 0x18,0x03,0x20,0x03, 0x20,0x02, 0x1F,0x03, 0x1B,0x03, 0x1F,0x66,0x20,0x03, 0x21,0x03, 0x20,0x03, 0x1F,0x03, 0x1B,0x03,0x1F,0x66, 0x1F,0x04, 0x1B,0x0E, 0x1B,0x03, 0x19,0x03,0x19,0x03, 0x15,0x03, 0x1A,0x66, 0x1A,0x03, 0x19,0x03,0x15,0x03, 0x15,0x03, 0x17,0x03, 0x16,0x66, 0x17,0x04,0x18,0x04, 0x18,0x03, 0x19,0x03, 0x1F,0x03, 0x1B,0x03,0x1F,0x66, 0x20,0x03, 0x21,0x03, 0x20,0x03, 0x1F,0x03,0x1B,0x03, 0x1F,0x66, 0x1F,0x03, 0x1B,0x03, 0x19,0x03,0x19,0x03, 0x15,0x03, 0x1A,0x66, 0x1A,0x03, 0x19,0x03,0x19,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x00, 0x18,0x02,0x18,0x03, 0x1A,0x03, 0x19,0x0D, 0x15,0x03, 0x15,0x02,0x18,0x66, 0x16,0x02, 0x17,0x02, 0x15,0x00, 0x00,0x00};//***********************************************************************************main(){int  temp;InitialSound();Play(Music_Girl,0,3,360);Delay1ms(500);while(1){  temp=ReadTemperature();//讀溫度bai=temp%1000/100;//顯示百位shi=temp%100/10;//顯示十位ge=temp%10;//顯示個(gè)位display(bai,shi,ge);//顯示函數(shù) }}/****************************

          上一頁 1 2 下一頁

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();