51单片机演奏天空之城 c语言源程序
来源:互联网 发布:java中dao是什么意思 编辑:程序博客网 时间:2024/05/08 21:43
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit beep=P1^0;
unsigned int C;
#define L1 262
#define L2 284
#define L3 311
#define L4 349
#define L5 392
#define L6 440
#define L7 494
#define Z1 523
#define Z2 587
#define Z3 659
#define Z4 698
#define Z5 784
#define Z6 880
#define Z7 987
#define H1 1046
#define H2 1174
#define H3 1318
#define H4 1396
#define H5 1567
#define H6 1760
#define H7 1975
void delay();
unsigned code GP[]={Z6,Z7,H1,Z7,H1,H3,Z7,Z3,Z6,Z5,Z6,H1,Z5,
Z3,Z3,Z4,Z3,H4,H1,Z3,H1,H1,Z7,Z4,Z4,Z7,
Z7,Z6,Z7,H1,Z7,H1,H3,Z7,Z3,Z6,Z5,Z6,H1,
Z5,Z2,Z3,Z4,H1,Z7,H1,H2,H2,H3,H1,H1,Z7,
Z6,Z6,Z7,Z5,Z6,H1,H2,H3,H2,H3,H5,H2,H1,
H1,Z7,H1,H3,H3,Z6,Z7,H1,Z7,H1,H2,H1,Z5,
Z5,H4,H3,H2,H1,H3,H3,H3,H6,H6,H5,H5,H3,
H2,H1,H1,H2,H1,H2,H5,H3,H3,H6,H6,H5,H5,
H3,H2,H1,H1,H2,H1,H2,Z7,Z6,Z6,0xff};
unsigned code JP[]={4,4,/**/12,4,8,8,/**/20,8,/**/12,4,8,8,
20,4,4,/**/12,4,8,8,/**/20,4,4,/**/12,4,8,8,
/**/20,4,4,/**/12,4,8,8,/**/20,8,/**/12,4,8,8,
/**/20,4,4,/**/8,4,12,3,1,/**/12,4,12,/**/4,4,
4,4,8,8,/**/20,4,4,/**/12,4,8,8,/**/24,/**/
8,4,4,8,8,/**/24,/**/4,4,8,4,4,8,/**/12,4,12,
/**/8,8,8,4,4,/**/16,8,/**/12,4,12,4,/**/4,4,12,8,
/**/12,4,8,8,/**/16,8,/**/12,4,12,4,/**/4,4,12,8,
/**/12,4,8,3,1,/**/32};
void main()
{ uchar i,j;
TMOD=0x00;
EA=1; //开总中断
ET0=1; //开t0中断
while(1)
{ i=0;
while(GP[i]!=0xff)
{C=460830/GP[i];
TH0=(8192-C)/32;
TL0=(8192-C)%32;
TR0=1;//开定时器0
for(j=0;j<JP[i];j++)
{delay();}
TR0=0;
i++;
}
beep=0;
}
}
void delay() //延时15.6ms
{
uint i,j;
for(i=70;i>0;i--)
{for(j=110;j>0;j--);}
}
void T0_time()interrupt 1
{ TR0=0;
beep=!beep;
TH0=(8192-C)/32;
TL0=(8192-C)%32;
TR0=1;
}
0 0
- 51单片机演奏天空之城 c语言源程序
- 51单片机-播放天空之城
- 标题:51单片机流水灯C语言源程序
- 51单片机之串口操作入门经验总结与C源程序
- 51单片机演奏乐曲的程序
- C语言之51单片机中的数据类型
- 单片机演奏《上海滩》
- 51单片机IO口模拟串口通讯C源程序
- C语言 HelloWorld源程序
- crc8 c语言源程序
- crc8 c语言源程序
- 51单片机C语言开发之花样流水灯程序
- 51单片机-C语言之while(!x)的理解
- 51单片机 C语言入门教程
- 51单片机 C语言电子琴
- 实战:用单片机演奏音乐
- linux学习之C语言(1)------ 源程序的编译
- 菜鸟之学习51单片机(二)单片机C语言基础
- 【LeetCode】126. Word Ladder II【H】
- Tango 开发指南(4) — 事件
- Palindrome Linked List问题及解法
- 关于try finally解惑
- 【MySql】The slave I/O thread stops because master and slave have equal MySQL server UUIDs;
- 51单片机演奏天空之城 c语言源程序
- 欢迎使用CSDN-markdown编辑器
- 水仙花数
- 手机网站支付转Native支付--Android
- "尚学堂杯"哈尔滨理工大学第七届程序设计竞赛 B.Blind Father(贪心)
- 解读Qt OpenGL示例程序 openglwindow
- 【MySql】主从配置
- apache在没有index.html时显示目录文件列表
- Kali Linux 2.0 2016.2 安装VMware tools方法