/*********************************************************************************************
程序名: 8键电子琴C程序
编写人: 杜洋
编写时间: 2009年5月18日
硬件支持: STC系列单片机 12MHz
接口说明:
修改日志:
NO.1-
/*********************************************************************************************
说明:
/*********************************************************************************************/
#include
#define uchar unsigned char
#define KEY P3
#define LED P1
sbit dula=P2^6; //段选信号的锁存器控制
sbit wela=P2^7; //位选信号的锁存器控制
sbit SPEAKER = P2^3;
bit flag; //标志音乐输出脚电平的高低
uchar ptr = 0x00; //取音符
uchar high; //计数器高位
uchar low; //计数器低位
unsigned char KeyValue;
unsigned char KeyValue2;
unsigned char STH0;
unsigned char STL0;
unsigned char i;
unsigned char lednum=0;
/*unsigned int code tab[]={
64021,64103,64260,64400,//低音3开始
64524,64580,64684,64777,
64820,64898,64968,65030,
65058,65110,65157,65178
}; */
unsigned int code tab[]={
/*10000,64103,64260,64400,//低音3开始 */
64580,64633,64684,64732,
64777,64820,64860,64898,
64934,64968,64994,65030
};
unsigned int code music[] ={
4 ,6 ,8, 9 ,11,13,15
};
unsigned char code music2[] = {
// 1 _ 1_ 1 .5
0xFC,0x44,0x7F, 0xFC,0x44,0x7F, 0xFC,0x44,0xFF, 0xFA,0x68,0xFF,
// 3 _ 3_ 3 1
0xFD,0x23,0x7F, 0xFD,0x23,0x7F, 0xFD,0x23,0xFF, 0xFC,0x44,0xFF,
// 1_ 3_ 5 5
0xFC,0x44,0x7F, 0xFD,0x23,0x7F, 0xFD,0x82,0xFF, 0xFD,0x82,0xFF,
// 4_ 3_ 2 -
0xFD,0x23,0x7F, 0xFD,0x23,0x7F, 0xFC,0xAC,0xFF, 0xFF,0xFF,0xFF,
// 2_ 3_ 4 4
0xFC,0xAC,0x7F, 0xFD,0x23,0x7F, 0xFD,0x34,0xFF, 0xFD,0x34,0xFF,
// 3_ 2_ 3 1
0xFD,0x23,0x7F, 0xFC,0xAC,0x7F, 0xFD,0x23,0xFF, 0xFC,0x44,0xFF,
// 1_ 3_ 2 .5