音樂播放器程序源代碼及注釋_第1頁
音樂播放器程序源代碼及注釋_第2頁
音樂播放器程序源代碼及注釋_第3頁
音樂播放器程序源代碼及注釋_第4頁
音樂播放器程序源代碼及注釋_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、音樂播放器程序源代碼及注釋:#include <reg52.h>#define uchar unsigned char#define uint unsigned intsbit duan=P26;sbit key1=P32;/按key1可切換花樣sbit key2=P33;/按key2可切換歌曲sbit fm=P24;/蜂鳴器連續(xù)的IO口sbit P30=P30;/矩陣鍵盤的一列uchar code huayang1=0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf;/花樣1uchar cod

2、e huayang2=0x7f,0xfe,0xbf,0xfd,0xdf,0xfb,0xef,0xf7,0xef,0xfb,0xdf,0xfd,0xbf,0xfe;/花樣2uchar code huayang3=0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff;char code huayang4= 0x55,0xaa,0xcc,0x33,0x99,0x66,0x0f,0xf0;uchar count1;/花樣標(biāo)志uchar count2;/歌曲標(biāo)志uchar timeh,timel,i;

3、/編程規(guī)則:字節(jié)高位是簡譜,低位是持續(xù)時(shí)間,/代表多少個(gè)十六分音符/1-7代表中央C調(diào),8-E代表高八度,0代表停頓/最后的0是結(jié)束標(biāo)志uchar code qnzl= /千年之戀0x12,0x22,0x34,0x84,0x74,0x54,0x38,0x42,0x32,0x22,0x42,0x34,0x84,0x72,0x82,0x94,0xA8,0x08,/前奏0x32,0x31,0x21,0x32,0x52,0x32,0x31,0x21,0x32,0x62,/竹林的燈火 到過的沙漠0x32,0x31,0x21,0x32,0x82,0x71,0x81,0x71,0x51,0x32,0x22,

4、/七色的國度 不斷飄逸風(fēng)中0x32,0x31,0x21,0x32,0x52,0x32,0x31,0x21,0x32,0x62,/有一種神秘 灰色的旋渦 0x32,0x31,0x21,0x32,0x83,0x82,0x71,0x72,0x02,/將我卷入了迷霧中 0x63,0xA1,0xA2,0x62,0x92,0x82,0x52,/看不清的雙手 0x31,0x51,0x63,0x51,0x63,0x51,0x63,0x51,0x62,0x82,0x7C,0x02,/一朵花傳來誰經(jīng)過的溫柔 0x61,0x71,0x82,0x71,0x62,0xA2,0x71,0x76,/穿越千年的傷痛 0x61

5、,0x71,0x82,0x71,0x62,0x52,0x31,0x36,/只為求一個(gè)結(jié)果 0x61,0x71,0x82,0x71,0x62,0xA3,0x73,0x62,0x53,/你留下的輪廓 指引我 0x42,0x63,0x83,0x83,0x91,0x91,/黑夜中不寂寞 0x61,0x71,0x82,0x71,0x62,0x0A2,0x71,0x76,/穿越千年的哀愁 0x61,0x71,0x82,0x71,0x62,0x52,0x31,0x36,/是你在盡頭等我 0x61,0x71,0x82,0x71,0x62,0xA3,0x73,0x62,0x53,/最美麗的感動(dòng) 會(huì)值得 0x42

6、,0x82,0x88,0x02,0x74,0x93,0x89,0xff/結(jié)束標(biāo)志/用一生守候;uchar code jmszl= /寂寞沙洲冷0x12,0x12,0x22,0x32,0x31,0x22,0x21,0x22,/自你走后心憔悴0x21,0x31,0x51,0x52,0x31,0x52,0x61,0x15,0x14,/白色油桐風(fēng)中紛飛0x51,0x52,0x31,0x52,0x62,0x13,0x11,0x13,0x32,0x28,0x08,0x28,/落花似人有情 這個(gè)季節(jié)0x31,0x32,0x31,0x32,0x11,0x21,0x51,0x52,0x51,0x52,/河畔的風(fēng)

7、放肆拼命地吹0x51,0x51,0x31,0x32,0x31,0x32,0x81,0x72,0x63,/不斷撥弄離人的眼淚0x62,0x71,0x81,0x72,0x61,0x61,0x52,0x31,0x21,0x32,0x51,0x54,/那樣濃烈的愛再也無法給0x22,0x12,0x11,0x12,0x11,0x12,0x12,0x14,0x26,0x32,0x26,/傷感一夜一夜0x32,0x61,0x51,0x51,0x31,0x31,0x21,0x31,0x51,0x61,0x51,0x31,0x51,/當(dāng)記憶的線纏繞過往支離破碎0x02,0x32,0x81,0x81,0x81,0

8、x81,0x62,0x52,0x34,/是慌亂占據(jù)了心扉 0x31,0x81,0x81,0x81,0x61,0x91,0x82,/有花兒伴著蝴蝶0x51,0x51,0x51,0x51,0x31,0x61,0x53,/孤雁可以雙飛0x21,0x11,0x21,0x11,0x22,0x11,0x21,0x26,/夜深人靜獨(dú)徘徊0x32,0x61,0x51,0x51,0x31,0x31,0x21,0x31,0x51,0x61,0x51,0x31,0x51,0x52,/當(dāng)幸福戀人寄來紅色分享喜悅0x31,0x31,0x81,0x81,0x81,0x61,0x91,0x81,0x61,0x31,0x56

9、,/閉上雙眼難過頭也不敢回0x32,0x32,0x81,0x81,0x81,0x81,0x91,0x81,0x61,0x81,0x61,0x51,0x31,0x51,0x34,/仍然撿盡寒枝不肯安歇微帶著后悔0x21,0x31,0x51,0x31,0x21,0x11,0x61,0x21,0x16,/寂寞沙洲我該思念誰0xff;uchar code cuzhi= 0xff,0xff,/占位 0xFC,0x8E,/中央C調(diào)1-7 0xFC,0xED, 0xFD,0x43, 0xFD,0x6A, 0xFD,0xB3, 0xFD,0xF3, 0xFE,0x2D, 0xFE,0x47,/高八度1-7 0

10、xFE,0x76, 0xFE,0xA1, 0xFE,0xC7, 0xFE,0xD9, 0xFE,0xF9, 0xFF,0x16 ;uchar yinyue=0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x0,0x0;/將音調(diào)轉(zhuǎn)化為對應(yīng)的LED樣式void delay1(uint z);/延時(shí)1MSvoid delay(uint z);/延時(shí)165MS,即十六分音符void song();void beep();/蜂鳴器叫一聲main()uchar x;count1=0;/流水燈無花樣count2=1;/唱第一首歌P30=0;/選取矩陣鍵盤的一列EA

11、=1;/開總中斷EX0=1;/開外部中斷0IT0=1;/外部中斷0下降沿觸發(fā)方式EX1=1;/開外部中斷1IT1=1;/外部中斷1下降沿觸發(fā)方式TMOD=0x01;/定時(shí)器0工作在方式1TH0=0;TL0=0;ET0=1;while(1)if(count1!=0)switch(count1)case 1:for(x=0;x<14;x+)duan=1;P1=huayang1x;beep();delay1(300);duan=0;if(count1!=1)break;break;case 2:for(x=0;x<14;x+)duan=1;P1=huayang2x;beep();dela

12、y1(300);duan=0;if(count1!=2)break;break;case 3:for(x=0;x<16;x+)duan=1;P1=huayang3x;beep();delay1(300);duan=0;if(count1!=3)break;break;case 4:for(x=0;x<8;x+)duan=1;P1=huayang4x;beep();delay1(300);duan=0;if(count1!=4)break;break;elsesong();delay1(1000); void int0() interrupt 0EA=0;/關(guān)總中斷delay1(1)

13、;/去抖if(key1=0)count2=0;/不讓蜂鳴器唱歌TR0=0;count1+;if(count1=5) count1=1;EA=1;/開總中斷void int1() interrupt 2EA=0;/關(guān)總中斷delay1(1);/去抖if(key2=0)count1=0;/流水燈無花樣TR0=1;i=0;/從頭開始唱count2+;if(count2=3) count2=1;EA=1;/開總中斷void timer0() interrupt 1 /用于產(chǎn)生各種音調(diào)TH0=timeh;TL0=timel;fm=fm;void song()uint temp;uchar jp;/jp是簡譜i=0;while(1)if(count2=0)break;if(count2=1)/選曲 temp=qnzli;if(count2=2)temp=jmszli;if(temp=0xff)break;jp=temp/16; /取數(shù)的高4位duan=1;P1=yinyuejp;duan=0;if(jp!=0)timeh=cuzhijp*2;timel=cuzhijp*2+1;elseTR0=0;fm=1;/關(guān)蜂鳴器delay(temp%16); /取數(shù)的低4位TR0=0; /唱完一個(gè)音停10MSfm=1;delay1(10); TR0=1; i+;TR0=0;fm=1;void

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論