版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、#include #include #include code unsigned char table[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //顯示段碼unsigned char code run[4]={ 0xf3,0xf9,0xfc,0xf6}; //步進(jìn)電機轉(zhuǎn)動數(shù)組unsigned char code SONG[] ={ //祝你平安 0x26,0
2、x20,0x20,0x20,0x20,0x20,0x26,0x10,0x20,0x10,0x20,0x80,0x26,0x20,0x30,0x20, 0x30,0x20,0x39,0x10,0x30,0x10,0x30,0x80,0x26,0x20,0x20,0x20,0x20,0x20,0x1c,0x20, 0x20,0x80,0x2b,0x20,0x26,0x20,0x20,0x20,0x2b,0x10,0x26,0x10,0x2b
3、,0x80,0x26,0x20, 0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,0x26,0x60,0x40,0x10,0x39,0x10,0x26,0x20, 0x30,0x20,0x30,0x20,0x39,0x10,0x26,0x10,0x26,0x80,0x26,0x20,0x2b,0x10,0x2b,0x10, 0x2b,0x20,0x30,0x10,0x39,0x10,0x26,0x10,0
4、x2b,0x10,0x2b,0x20,0x2b,0x40,0x40,0x20, 0x20,0x10,0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x18,0x20,0x18,0x20,0x26,0x20, 0x20,0x20,0x20,0x40,0x26,0x20,0x2b,0x20,0x30,0x20,0x30,0x20,0x1c,0x20,0x20,0x20, 0x20,0x80,0x1c,0x2
5、0,0x1c,0x20,0x1c,0x20,0x30,0x20,0x30,0x60,0x39,0x10,0x30,0x10, 0x20,0x20,0x2b,0x10,0x26,0x10,0x2b,0x10,0x26,0x10,0x26,0x10,0x2b,0x10,0x2b,0x80, 0x18,0x20,0x18,0x20,0x26,0x20,0x20,0x20,0x20,0x60,0x26,0x10,0x2b,0x20,0x30,0
6、x20, 0x30,0x20,0x1c,0x20,0x20,0x20,0x20,0x80,0x26,0x20,0x30,0x10,0x30,0x10,0x30,0x20, 0x39,0x20,0x26,0x10,0x2b,0x10,0x2b,0x20,0x2b,0x40,0x40,0x10,0x40,0x10,0x20,0x10, 0x20,0x10,0x2b,0x10,0x26,0x30,0x30,0x80,0x00,//路邊的野華不
7、要采 0x30,0x1C,0x10,0x20,0x40,0x1C,0x10,0x18,0x10,0x20,0x10,0x1C,0x10,0x18,0x40,0x1C, 0x20,0x20,0x20,0x1C,0x20,0x18,0x20,0x20,0x80,0xFF,0x20,0x30,0x1C,0x10,0x18,0x20, 0x15,0x20,0x1C,0x20,0x20,0x20,0x26,0x40,0x20,0x20,0x2B,
8、0x20,0x26,0x20,0x20,0x20, 0x30,0x80,0xFF,0x20,0x20,0x1C,0x10,0x18,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30, 0x20,0x2B,0x40,0x20,0x20,0x1C,0x10,0x18,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30, 0x20,0x2B,0x40,0x20,0x30,0x1C,0x
9、10,0x18,0x20,0x15,0x20,0x1C,0x20,0x20,0x20,0x26, 0x40,0x20,0x20,0x2B,0x20,0x26,0x20,0x20,0x20,0x30,0x80,0x20,0x30,0x1C,0x10,0x20, 0x10,0x1C,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20,0x15,0x1F, 0x05,0x20
10、,0x10,0x1C,0x10,0x20,0x20,0x26,0x20,0x2B,0x20,0x30,0x20,0x2B,0x40,0x20, 0x30,0x1C,0x10,0x18,0x20,0x15,0x20,0x1C,0x20,0x20,0x20,0x26,0x40,0x20,0x20,0x2B, 0x20,0x26,0x20,0x20,0x20,0x30,0x30,0x20,0x30,0x1C,0x10,0x18,0x40,0x
11、1C,0x20,0x20, 0x20,0x26,0x40,0x13,0x60,0x18,0x20,0x15,0x40,0x13,0x40,0x18,0x80,0x00,};unsigned char Count;static signed int tcnt,sec,time0=0; //定時時間unsigned char number; //轉(zhuǎn)速控制,數(shù)值越大電機轉(zhuǎn)速越慢反之則快unsigned char num;//步進(jìn)電機的轉(zhuǎn)速
12、bit write=0; //寫 24C08 的標(biāo)志;sbit signal=P3^4;//信號檢測通道 sbit sda=P3^6; // 24c08 SDA sbit scl=P3^7; // 24c08 SCLsbit stsp=P1^4; //啟動/停止sbit mlac=P1^5; //手動/自動sbit add=P1^3; //加速按鍵sbit dec=P1^2; //減速按鍵sbit time=P1^6
13、; //定時按鍵sbit qebn=P1^7;//定量按鍵sbit you=P1^1; //加時/加量按鍵sbit zuo=P1^0;//減時/減量按鍵sbit _Speak=P3^5 ; //訊響器控制腳//*******************步進(jìn)電機驅(qū)動程序開始**********************//void delay2(unsigned char i)//延時函數(shù){unsigned char j,k;for(j
14、=0;j9999 | sec<0) sec=5000;}}//*************步進(jìn)電機驅(qū)動程序結(jié)束****************////**************報警信號***************************// void Time0_Int() interrupt 3 { TH1 = 0xD8; TL1 = 0xEF; Count++; //長度加 1 }v
15、oid Delay_xMs(unsigned int x) //1MS 延時子程序 { unsigned int i,j; for( i =0;i < x;i++ ) {for( j =0;j<3;j++ );} }void Play_Song(unsigned char i) //:歌曲播放子程序 i 為播放哪一段曲目 { unsigned char Temp1,Temp2; unsigned int Addr;Count
16、 = 0; //中斷計數(shù)器清 0 Addr = i * 217; while(1) { Temp1 = SONG[Addr++];if( Temp1 == 0xFF ) //休止符 {TR1 = 0; Delay_xMs(100); }else if ( Temp1 == 0x00 ) //歌曲結(jié)束符 {return;} else {Temp2 = SONG[Addr++]; TR1 = 1; while(1) { _Speak = ~
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
評論
0/150
提交評論