基于单片机的音乐播放器

  • 格式:docx
  • 大小:380.91 KB
  • 文档页数:38

摘要

摘要

现如今,单片机的应用无处不在。利用单片机控制的音乐播放器也不胜枚举,音乐芯片也相当多,而利用单片机存储音乐,控制播放最为广泛。它有功能多、价格优、外部电路简单的特点,深受音乐爱好者及音乐芯片制造商的青睐,用STC89C52单片机及少数外部电路控制音乐播放,产生“祝你生日快乐”歌曲。

对于单片机产生音乐,关键是控制频率的输出。我们知道,不同的声音对应不同的频率,产生有规律的频率输出就可以得到响相应规律的声音。音乐中,有8个基本音符:do、re、mi、fa、so、la、xi、do,8个不同的音符对应着不同的频率。只要我们找最与音符输出相应的频率,就可以产生美妙的音乐了。本章中采用了T0中断的方法产生不同的频率,并用两键控制播放和停止。

【关键词】:单片机;硬件系统;软件系统;控制程序结构

ABSTRACT

ABSTRACT

Now today, SCM applications are ubiquitous. Music played by using

single-chip microcomputer control also not more ShengJu, music chip is

also quite, but using single chip computer storage music, control

broadcast the most widely used. It has the function is much, competitive

price and an external circuit simple features, deeply music lovers and

music chip maker STC89C52 SCM's favour, use external circuit control and

minority music playback, produce "happy birthday to you" song.

For microcontroller produce music, the key is to control frequency

output. We know that the different sound corresponding to different

frequency, produce regular frequency output can be ringing corresponding

laws of voice. Music, there are eight basic notes: do, re, mi, fa, so,

la, xi, do, eight different notes correspond to different frequencies.

As long as we most recruit notes output corresponding frequency, it can

produce wonderful music. This chapter is adopted in T0 interrupted the

method to create different frequencies, and two key control on and off.

【KEY WORD】:SCM ;Hardware system ;Software system Control ;program

structure

目录

1

目录

摘要 ...................................................................................................................................................... 1

ABSTRACT ........................................................................................................................................ 2

目录 ...................................................................................................................................................... 1

一、绪论 .............................................................................................................................................. 1

引言 .............................................................................................................................................. 1

1.单片机概述 ............................................................................................................................... 1

2.单片机的应用 ........................................................................................................................... 6

3.课题概述 ................................................................................................................................... 8

二、系统硬件原理及设计 .................................................................................................................. 9

1.STC89C52的结构 .................................................................................................................... 9

2.元器件介绍 ............................................................................................................................. 12

3.硬件电路设计 ......................................................................................................................... 13

播放模块 .................................................................................................................................... 15

三、系统软件原理 ............................................................................................................................ 17

1.软件流程图 ............................................................................................................................. 17

2.音频控制的原理: ................................................................................................................. 17

3.节拍控制的原理 ..................................................................................................................... 19

4.音调的宏定义 ......................................................................................................................... 19

5.音频压缩 .............................................................................................................................. 20

四、系统调试与仿真 ........................................................................................................................ 21

1.keil软件 .................................................................................................................................. 21 目录

2.keil编译调试 .......................................................................................................................... 21

3.protues软件 ............................................................................................................................ 22