51单片机电子琴源程序
- #include<reg51 h>
- #define uint unsigned int
- #define uchar unsigned char
- void?Init(void);//初始化
- void?Key_Scan(void);//键值扫描
- void?Delayms(uint?z);//延时
- void?LED_Display(void);//数码显示
- void?Sound_Player(void);//音频处理
- uint?Keycode;//键值
- uint?Time?=?0;
- uint?Flag?=?0;?
- uint?TH0code,TL0code;
- sbit?Speaker?=?P3^0;?//扬声器控制引脚
- uint?Num?=?0;?
- uchar?code?table[]={?//数码管共阴码表
- 0x3f,0x06,0x5b,0x4f,
- 0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f,0x77,0x7c,
- 0x39,0x5e,0x79,0x71};
- uchar code Music1_Tab[]={ //曲谱1码表
- 0xc0,0xf9,0xa4,0xb0,
- 0x99,0x92,0x82,0xf8,
- 0x80,0x90,0x88,0x83,
- 0xc6,0xa1,0x86,0x8e};
- uint code Music2_Tab[]={ //曲谱2码表
- 64021,64103,64260,64400,
- 64524,64580,64684,64777,
- 64820,64898,64968,65030,
- 65058,65110,65157,65178};
复制代码
|