单片机基于单片机的带音乐播放的电子琴设计

qq音乐不能播放  时间:2021-02-25  阅读:()

毕业设计论文任务书专业班 09电子3班 姓名 陈中乾 学号:课题名称、主要内容和基本要求

进度安排

指导教师评语

评阅教师评语

毕业设计论文成绩

答辩委员会主任签名

1.摘要

电子琴是现代电子科技与音乐结合的产物是一种新型的键盘乐器。它在现代音乐扮演着重要的角色单片机具有强大的控制功能和灵活的编程实现特性它已经溶入现代人们的生活中成为不可替代的一部分。本文的主要内容是用AT89S51单片机为核心控制元件设计一个电子琴。 以单片机作为主控核心与键盘、扬声器等模块组成核心主控制模块在主控模块上设有10个按键和扬声器。本系统运行稳定其优点是硬件电路简单软件功能完善控制系统可靠性价比较高等具有一定的实用和参考价值。

众所周知 由于一首音乐是由许多不同的音阶组合而成的而每个音阶则对应着不同的频率 因此我们可以利用不同的频率来进行音阶的组合 即可产生美妙的音乐了。

对于单片机来说产生不同的频率非常方便只要算出某一音频的周期然后将此周期除以2 即为半周期的时间利用定时器计时这个半周期时间每当计时到后就将输出脉冲的I/O反相然后重复计时此半周期再对I/O反相 即可在I/O脚上得到此频率的脉冲。因此我们可以利用单片机的定时器使其工作在计数器模式MODE1下改变计数值TH0及TL0来产生不同频率的信号。从而产生不同的音符[1] 。

关键词音阶频率单片机

2.Abstract

Electronic organ is a modern electronic music technology and the product is a new type ofkeyboard instruments. It played an important role in modern music.SCM has powerful contro l functions and flexible pro gramming characteristic s. It has converged with modern people's lives,become an irreplaceable part.The main content is AT89S51 control of the core components,design ofa electronic organ.SCM as a host to the core,with the keyboard, speaker and other core modules. In the main control module has 16 keys and a speaker.The system is steady, its simple hardware circuits, software functions,reliability of control system and high cost performance is its advantages.It also has certain practical and reference value.

Well-known, the music is made up by many different scales, and each scalecorresponds to different frequency, so we can use different frequency to makecombination of scales,and thenproduce wonderful music.

As for single-chip microcomputer, it is very convenient to produce differentfrequency,we just calculate an audio cycle, then this cycle divided by 2,namely halfcycle time,using timer to time the half cycle time.

Whenever timing, it will output pulse I/O reverse phase, and repeat the timing,the half cycle again to the I/O reversed-phase, then can get this frequency pulse fromthe I/O feet. So we can use microcontroller timer to make it work in the counter modeand generate different frequency signal.Thus produce different notes.

Keywords: scales,frequency, s ingle-chip microcomputer

目 录

第一章绪论. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

1. 1电子琴的特点及研究意义. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

1.2 系统介绍. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1

第二章方案论证. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2

2. 1单片机选择. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2

2.2键盘选择. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2

2.3功放电路选择. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

第三章系统设计. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

3. 1单片机的介绍. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

3. 1. 1单片机AT89S52基本知识. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

3. 1.2单片机AT89S52产品特点. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6

3. 1.3单片机AT89S52的使用. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6

3. 1.4单片机AT89S52的特性. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

3. 1.5 AT89S52引脚功能与封装. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

3.2 LED数码管. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

3.2. 1 LED数码管主要技术参数. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

3.2.2 LED数码管的引脚说明. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

3.2.3数码管编码说明. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

3.3 LM386. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

3.3. 1LM386简介. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

3.3.2 LM386特性. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

3.3.3 LM386应用特点. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

3.3.4 LM386引脚图. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

3.3.5 LM386注意事项. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14

第四章硬件设计. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

4. 1总体电路设计. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

4.2单片机最小系统电路. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16

4.3LM386功放电路. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16

4.4数码管显示电路. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17

4.5按键电路. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18

4.6按键指示灯电路. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19

4.7音乐产生方法. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19

第五章软件设计. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22

5. 1程序流程图. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22

5.2 S1-S8按键识别程序. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22

5.3 S9键识别电路程序. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24

5.4音乐产生程序. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25

第六章调试过程. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29

6. 1数码管显示乱码. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29

6.3按键处理问题. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29

结论. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29

参考文献. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30

谢辞. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31

附录. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32

附录一程序源代码. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32

附录二电路图. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45

ProfitServer$34.56/年,西班牙vps、荷兰vps、德国vps/不限制流量/支持自定义ISO

profitserver怎么样?profitserver是一家成立于2003的主机商家,是ITC控股的一个部门,主要经营的产品域名、SSL证书、虚拟主机、VPS和独立服务器,机房有俄罗斯、新加坡、荷兰、美国、保加利亚,VPS采用的是KVM虚拟架构,硬盘采用纯SSD,而且最大的优势是不限制流量,大公司运营,机器比较稳定,数据中心众多。此次ProfitServer正在对德国VPS(法兰克福)、西班牙v...

老薛主机入门建站月付34/月,年付345元,半价香港VPS主机

老薛主机怎么样?老薛主机这个商家有存在有一些年头。如果没有记错的话,早年老薛主机是做虚拟主机业务的,还算不错在异常激烈的市场中生存到现在,应该算是在众多商家中早期积累到一定的用户群的,主打小众个人网站业务所以能持续到现在。这不,站长看到商家有在进行夏季促销,比如我们很多网友可能有需要的香港vps主机季度及以上可以半价优惠,如果有在选择不同主机商的香港机房的可以看看老薛主机商家的香港vps。点击进入...

Hostinger 限时外贸美国主机活动 低至月12元且赠送1个COM域名

Hostinger 商家我们可能一些新用户不是太熟悉,因为我们很多新人用户都可能较多的直接从云服务器、独立服务器起步的。而Hostinger商家已经有将近十年的历史的商家,曾经主做低价虚拟主机,也是比较有知名度的,那时候也有接触过,不过一直没有过多的使用。这不这么多年过去,Hostinger商家一直比较稳妥的在运营,最近看到这个商家在改版UI后且产品上也在活动策划比较多。目前Hostinger在进...

qq音乐不能播放为你推荐
网页解密急急急~~谁知道怎么让所有的网页都设密码?以及破解的办法啊? 谢谢了谁帮帮我啊iphone5解锁iphone5密码忘了怎么解锁吴晓波频道买粉看吴晓波频道的心得网站运营刚创业的网站运营怎么做?童之磊华硕的四核平板电脑,怎么样?qq怎么发邮件qq怎么发文件和邮件ios7固件下载iOS7如何升级固件?创维云电视功能创维新出的4K超高清健康云电视有谁用过,功能效果怎么样?人人逛街人人逛街评论怎么不显示链接了?好像4月28日就不能显示了。是什么原因呢?idc前线求电影敢死队电影里的歌曲!
荷兰服务器 asp.net主机 themeforest kddi tk域名 网通代理服务器 嘉洲服务器 dd444 美国在线代理服务器 网游服务器 彩虹云 外贸空间 主机管理系统 秒杀品 全能空间 中国电信宽带测速 hdchina windowsserver2012r2 windowsserverr2 symantec 更多