基于51单片机的音乐盒设计.docx
《基于51单片机的音乐盒设计.docx》由会员分享,可在线阅读,更多相关《基于51单片机的音乐盒设计.docx(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、基于51单片机的音乐盒设计 基于51单片机的音乐盒设计 题目要求: 1. 查阅资料,了解单片机控制单音喇叭发声原理; 2. 设计基于单片机的电子音乐盒; 3通过按钮可选择不同的音乐,切换3首音乐; 运行仿真图: 程序完整代码: #include sbit fx_buzzer=P37; /蜂鸣器音乐输出,可根据需要自行修改 sbit music_1 = P20; /第一首音乐 sbit music_2 = P21; /第二首音乐 sbit music_3 = P22; /第二首音乐 unsigned int tone; /简谱音调计数 unsigned char fx_timeh,fx_time
2、l,music,speed; /fx_timeh:TH0初值,fx_timel:TL0初值; music =1播放,=0停止 unsigned char code fx_tone0= /音调对应定时器初值 0xFC,0x8E, 0xFC,0xED, 0xFD,0x43, /中音 0xFD,0x6A, 0xFD,0xB3, 0xFD,0xF3, 0xFE,0x2D, 0xFE,0x47, 0xFE,0x76, 0xFE,0xA1, /高音 0xFE,0xC7, 0xFE,0xD9, 0xFE,0xF9, 0xFF,0x16 ; unsigned char code songbie=/送别 0x5
3、4,0x32,0x52,0x88,0x64,0x84,0x58,0x54,0x12,0x22,0x34,0x22,0x12,0x2c,0x04, 0x54,0x32,0x52,0x86,0x72,0x64,0x84,0x58,0x54,0x22,0x32,0x46,0x72,0x1c, 0x64,0x8c,0x74,0x62,0x72,0x88,0x62,0x72,0x82,0x62,0x52,0x32,0x12,0x2f, 0x54,0x32,0x52,0x86,0x72,0x64,0x84,0x58,0x54,0x22,0x32,0x46,0x72,0x1c, 0x64,0x8c,0x74
4、,0x62,0x72,0x88,0x62,0x72,0x82,0x62,0x52,0x32,0x12,0x2f, 0x54,0x32,0x52,0x86,0x72,0x64,0x84,0x58,0x54,0x22,0x32,0x46,0x72,0x1c, 0xff; unsigned char 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,0x3
5、2,0x62,0x32,0x31, 0x21,0x32,0x82,0x71,0x81,0x71,0x51,0x32,0x22,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,0x
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 51 单片机 音乐盒 设计
限制150内