音乐播放器程序源代码及注释_第1页
音乐播放器程序源代码及注释_第2页
音乐播放器程序源代码及注释_第3页
音乐播放器程序源代码及注释_第4页
音乐播放器程序源代码及注释_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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;/蜂鸣器连续的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;/花样标志uchar count2;/歌曲标志uchar timeh,timel,i;

3、/编程规则:字节高位是简谱,低位是持续时间,/代表多少个十六分音符/1-7代表中央C调,8-E代表高八度,0代表停顿/最后的0是结束标志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、/七色的国度 不断飘逸风中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,/一朵花传来谁经过的温柔 0x61,0x71,0x82,0x71,0x62,0xA2,0x71,0x76,/穿越千年的伤痛 0x61

5、,0x71,0x82,0x71,0x62,0x52,0x31,0x36,/只为求一个结果 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,/最美丽的感动 会值得 0x42

6、,0x82,0x88,0x02,0x74,0x93,0x89,0xff/结束标志/用一生守候;uchar code jmszl= /寂寞沙洲冷0x12,0x12,0x22,0x32,0x31,0x22,0x21,0x22,/自你走后心憔悴0x21,0x31,0x51,0x52,0x31,0x52,0x61,0x15,0x14,/白色油桐风中纷飞0x51,0x52,0x31,0x52,0x62,0x13,0x11,0x13,0x32,0x28,0x08,0x28,/落花似人有情 这个季节0x31,0x32,0x31,0x32,0x11,0x21,0x51,0x52,0x51,0x52,/河畔的风

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,/当记忆的线缠绕过往支离破碎0x02,0x32,0x81,0x81,0x81,0

8、x81,0x62,0x52,0x34,/是慌乱占据了心扉 0x31,0x81,0x81,0x81,0x61,0x91,0x82,/有花儿伴着蝴蝶0x51,0x51,0x51,0x51,0x31,0x61,0x53,/孤雁可以双飞0x21,0x11,0x21,0x11,0x22,0x11,0x21,0x26,/夜深人静独徘徊0x32,0x61,0x51,0x51,0x31,0x31,0x21,0x31,0x51,0x61,0x51,0x31,0x51,0x52,/当幸福恋人寄来红色分享喜悦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调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;/将音调转化为对应的LED样式void delay1(uint z);/延时1MSvoid delay(uint z);/延时165MS,即十六分音符void song();void beep();/蜂鸣器叫一声main()uchar x;count1=0;/流水灯无花样count2=1;/唱第一首歌P30=0;/选取矩阵键盘的一列EA

11、=1;/开总中断EX0=1;/开外部中断0IT0=1;/外部中断0下降沿触发方式EX1=1;/开外部中断1IT1=1;/外部中断1下降沿触发方式TMOD=0x01;/定时器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;/关总中断delay1(1)

13、;/去抖if(key1=0)count2=0;/不让蜂鸣器唱歌TR0=0;count1+;if(count1=5) count1=1;EA=1;/开总中断void int1() interrupt 2EA=0;/关总中断delay1(1);/去抖if(key2=0)count1=0;/流水灯无花样TR0=1;i=0;/从头开始唱count2+;if(count2=3) count2=1;EA=1;/开总中断void timer0() interrupt 1 /用于产生各种音调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; /取数的高4位duan=1;P1=yinyuejp;duan=0;if(jp!=0)timeh=cuzhijp*2;timel=cuzhijp*2+1;elseTR0=0;fm=1;/关蜂鸣器delay(temp%16); /取数的低4位TR0=0; /唱完一个音停10MSfm=1;delay1(10); TR0=1; i+;TR0=0;fm=1;void

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论