资源简介
利用定时器和蜂鸣器唱歌,注释详细,正常编译通过,已经在单片机中测试过。
代码片段和文件信息
#include “reg52.h“
unsigned char Count;
sbit _Speak =P2^3 ; //讯响器控制脚
unsigned char code SONG[] ={ //祝你平安
0x260x200x200x200x200x200x260x100x200x100x200x800x260x200x300x20
0x300x200x390x100x300x100x300x800x260x200x200x200x200x200x1c0x20
0x200x800x2b0x200x260x200x200x200x2b0x100x260x100x2b0x800x260x20
0x300x200x300x200x390x100x260x100x260x600x400x100x390x100x260x20
0x300x200x300x200x390x100x260x100x260x800x260x200x2b0x100x2b0x10
0x2b0x200x300x100x390x100x260x100x2b0x100x2b0x200x2b0x400x400x20
0x200x100x200x100x2b0x100x260x300x300x800x180x200x180x200x260x20
0x200x200x200x400x260x200x2b0x200x300x200x300x200x1c0x200x200x20
0x200x800x1c0x200x1c0x200x1c0x200x300x200x300x600x390x100x300x10
0x200x200x2b0x100x260x100x2b0x100x260x100x260x100x2b0x100x2b0x80
0x180x200x180x200x260x200x200x200x200x600x260x100x2b0x200x300x20
0x300x200x1c0x200x200x200x200x800x260x200x300x100x300x100x300x20
0x390x200x260x100x2b0x100x2b0x200x2b0x400x400x100x400x100x200x10
0x200x100x2b0x100x260x300x300x800x00
//路边的野华不要采
0x300x1C0x100x200x400x1C0x100x180x100x200x100x1C0x100x180x400x1C
0x200x200x200x1C0x200x180x200x200x800xFF0x200x300x1C0x100x180x20
0x150x200x1C0x200x200x200x260x400x200x200x2B0x200x260x200x200x20
0x300x800xFF0x200x200x1C0x100x180x100x200x200x260x200x2B0x200x30
0x200x2B0x400x200x200x1C0x100x180x100x200x200x260x200x2B0x200x30
0x200x2B0x400x200x300x1C0x100x180x200x150x200x1C0x200x200x200x26
0x400x200x200x2B0x200x260x200x200x200x300x800x200x300x1C0x100x20
0x100x1C0x100x200x200x260x200x2B0x200x300x200x2B0x400x200x150x1F
0x050x200x100x1C0x100x200x200x260x200x2B0x200x300x200x2B0x400x20
0x300x1C0x100x180x200x150x200x1C0x200x200x200x260x400x200x200x2B
0x200x260x200x200x200x300x300x200x300x1C0x100x180x400x1C0x200x20
0x200x260x400x130x600x180x200x150x400x130x400x180x800x00
};
void Time0_Init()
{
TMOD = 0x01;
IE = 0x82;
TH0 = 0xD8;
TL0 = 0xEF; //12MZ晶振,10ms
}
void Time0_Int() interrupt 1
{
TH0 = 0xD8;
TL0 = 0xEF;
Count++; //长度加1
}
/*-------------------------------------------------
功能:1MS延时子程序
-------------------------------------------------*/
void Delay_xMs(unsigned int x)
{
unsigned int ij;
for( i =0;i < x;i++ )
{
for( j =0;j<3;j++ );
}
}
/*-------------------------------------------------
功能:歌曲播放子程序i为播放哪一段曲目
-------------------------------------------------*/
void Play_Song(unsigned char i)
{
unsigned char Temp1Temp2;
unsigned int Addr;
Count = 0; //中断计数器清0
Addr = i * 217;
while(1)
{
Temp1 = SONG[Addr++];
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3704 2006-04-15 06:18 fengmingqi.c
文件 1748 2018-08-17 11:55 fengmingqi.hex
- 上一篇:随机信号分析常建平课后答案
- 下一篇:网络编程期末试卷华南农业大学2011含答案
相关资源
- 基于PROTEUS的单片机多路温度采集系统
- 基于51单片机的温度显示报警系统
- 51单片机室温 体温测量
- 基于51单片机的ds18b20温度传感器实现
- 基于51单片机的温度报警系统
- 基于单片机的火灾报警器
- 基于51单片机矩阵按键电子琴设计-完
- 基于51单片机的水箱水位检测系统.r
- 基于单片机的公交车报站系统的设计
- 基于52单片机自动空调加PROTEUS仿真
- 基于单片机的无线多路温度传输
- 51单片机点阵俄罗斯方块代码
- 51单片机Protues,仿真PT100温度传感器,
- 基于AT89C51单片机的家庭防盗报警系统
- 基于51单片机的温度报警
- 基于51单片机的智能调光台灯源码+原
- μC/OS-II在MCS-51单片机移植
- 基于stc89c52单片机的节拍音乐器设计
- 基于51单片机AD7705使用的C程序
- 两片74HC595显示4位数码程序(C51单片机
- 基于C51单片机多功能时钟系统
- 基于51单片机的10位DA芯片 TLC5615的C应
- PID算法之msp430单片机实现
- 按键控制lcd液晶屏的显示的程序
- 嵌入式系统图形界面 GUI 基于51单片机
- 基于DSP和单片机的超声波测距系统
- 代码及原理图 2
- 单片机C51自动循迹小车程序
- 1602+ds1302+18B20万年历显示温度星期完全
- 51单片机控制智能恒温混水阀
评论
共有 条评论