#include #define uchar unsigned char #define uchar unsigned char #define uint unsigned int #define LCDPORT P0 uchar code tab[]="Press key"; uchar code tab1[]="Select song"; uchar code tab2[]="First Song" ; uchar code tab3[]="butterfly"; uchar code tab4[]="Second Song" ; uchar code tab5[]="Jingle bell "; uchar code tab6[]="Third Song" ; uchar code tab7[]="Yesterday"; uchar code tab8[]="Forth Song" ; uchar code tab9[]="Youth League"; sbit LCDE=P2^2; sbit LCDRW=P2^1; sbit LCDRS=P2^0; #define SYSTEM_OSC 12000000 //定义晶振频率12000000HZ #define SOUND_SPACE 4/5 //定义普通音符演奏的长度分率,//每4分音符间隔 sbit BeepIO = P3^7; //定义输出管脚 sbit K1=P1^7; unsigned int code FreTab[12] = { 262,277,294,311,330,349,369,392,415,440,466,494 }; //原始频率表 unsigned char code SignTab[7] = { 0,2,4,5,7,9,11 }; //1~7在频率表中的位置 unsigned char code LengthTab[7]= { 1,2,4,8,16,32,64 }; unsigned char Sound_Temp_TH0,Sound_Temp_TL0; //音符定时器初值暂存 unsigned char Sound_Temp_TH1,Sound_Temp_TL1; unsigned char code Music_Girl[]= { 0x1B,0x02, 0x1A,0x02, 0x1B,0x02, 0x19,0x66, 0x1A,0x03, 0x18,0x02, 0x17,0x02, 0x16,0x0D, 0x17,0x03, 0x18,0x0D, 0x17,0x03, 0x19,0x66, 0x17,0x03, 0x16,0x0D, 0x17,0x03, 0x19,0x0D, 0x16,0x03, 0x17,0x0D, 0x18,0x03, 0x17,0x0D, 0x16,0x03, 0x15,0x00, 0x19,0x02, 0x11,0x02, 0x16,0x02, 0x10,0x02, 0x15,0x02, 0x0F,0x00, 0x10,0x03, 0x15,0x03, 0x0F,0x00, 0x0D,0x01, 0x0F,0x66, 0x10,0x03, 0x15,0x66, 0x16,0x03, 0x10,0x0D, 0x15,0x03, 0x0F,0x03, 0x19,0x66, 0x1F,0x03, 0x1A,0x0D, 0x19,0x03, 0x17,0x03, 0x19,0x03, 0x16,0x00, 0x16,0x66, 0x17,0x03, 0x11,0x0C, 0x10,0x02, 0x19,0x66, 0x10,0x03, 0x15,0x02, 0x16,0x02, 0x0D,0x02, 0x15,0x02, 0x10,0x0D, 0x0F,0x03, 0x10,0x0D, 0x15,0x03, 0x0F,0x00, 0x17,0x66, 0x19,0x03, 0x11,0x02, 0x16,0x02, 0x10,0x0D, 0x15,0x03, 0x0F,0x15, 0x0D,0x03, 0x0F,0x02, 0x0D,0x03, 0x0F,0x0D, 0x10,0x03, 0x11,0x0D, 0x16,0x03, 0x10,0x00, 0x0F,0x0D, 0x10,0x03, 0x15,0x66, 0x16,0x03, 0x19,0x02, 0x17,0x02, 0x16,0x02, 0x17,0x0D, 0x16,0x03, 0x15,0x02, 0x10,0x0D, 0x0F,0x03, 0x0D,0x01, 0x15,0x01, 0x10,0x03, 0x15,0x04, 0x10,0x0D, 0x0F,0x03, 0x0D,0x0D, 0x0F,0x03, 0x10,0x0D, 0x15,0x03, 0x0F,0x00, 0x17,0x0D, 0x19,0x03, 0x16,0x0D, 0x17,0x03, 0x16,0x0D, 0x15,0x03, 0x11,0x02, 0x10,0x02, 0x0F,0x00, 0x00,0x00 }; unsigned char code Music_Jingle[]={ 0x0F,0x03, 0x0F,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x0F,0x66, 0x19,0x04, 0x19,0x04, 0x0F,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x02, 0x10,0x03, 0x10,0x03, 0x18,0x03, 0x17,0x03, 0x16,0x03, 0x10,0x66, 0x10,0x03, 0x19,0x03, 0x19,0x03, 0x18,0x03, 0x16,0x03, 0x17,0x02, 0x15,0x03, 0x0F,0x03, 0x0F,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x0F,0x66, 0x0F,0x03, 0x0F,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x66, 0x10,0x03, 0x10,0x03, 0x18,0x03, 0x17,0x03, 0x16,0x03, 0x19,0x03, 0x19,0x03, 0x19,0x03, 0x19,0x03, 0x1A,0x03, 0x19,0x03, 0x18,0x03, 0x16,0x03, 0x15,0x66, 0x17,0x03, 0x17,0x03, 0x17,0x02, 0x17,0x03, 0x17,0x03, 0x17,0x02, 0x17,0x03, 0x19,0x03, 0x15,0x03, 0x16,0x03, 0x17,0x01, 0x18,0x03, 0x18,0x03, 0x18,0x67, 0x18,0x04, 0x18,0x03, 0x17,0x03, 0x17,0x03, 0x17,0x04, 0x17,0x04, 0x17,0x03, 0x16,0x03, 0x16,0x03, 0x15,0x03, 0x16,0x03, 0x19,0x66, 0x19,0x03, 0x19,0x03, 0x18,0x03, 0x16,0x03, 0x15,0x02, 0x00,0x00 }; unsigned char code Music_Two[] ={ 0x17,0x03, 0x16,0x03, 0x17,0x01, 0x16,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x01, 0x10,0x03, 0x15,0x03, 0x16,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x03, 0x10,0x0E, 0x15,0x04, 0x0F,0x01, 0x17,0x03, 0x16,0x03, 0x17,0x01, 0x16,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x01, 0x10,0x03, 0x15,0x03, 0x16,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x03, 0x15,0x03, 0x16,0x01, 0x17,0x03, 0x16,0x03, 0x17,0x01, 0x16,0x03, 0x17,0x03, 0x16,0x03, 0x15,0x01, 0x10,0x03, 0x15,0x03, 0x16,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x03, 0x10,0x0E, 0x15,0x04, 0x0F,0x01, 0x17,0x03, 0x19,0x03, 0x19,0x01, 0x19,0x03, 0x1A,0x03, 0x19,0x03, 0x17,0x01, 0x16,0x03, 0x16,0x03, 0x16,0x02, 0x16,0x0D, 0x17,0x03, 0x16,0x03, 0x15,0x03, 0x10,0x03, 0x10,0x0D, 0x15,0x00, 0x19,0x03, 0x19,0x03, 0x1A,0x03, 0x1F,0x03, 0x1B,0x03, 0x1B,0x03, 0x1A,0x03, 0x17,0x0D, 0x16,0x03, 0x16,0x03, 0x16,0x0D, 0x17,0x01, 0x17,0x03, 0x17,0x03, 0x19,0x03, 0x1A,0x02, 0x1A,0x02, 0x10,0x03, 0x17,0x0D, 0x16,0x03, 0x16,0x01, 0x17,0x03, 0x19,0x03, 0x19,0x03, 0x17,0x03, 0x19,0x02, 0x1F,0x02, 0x1B,0x03, 0x1A,0x03, 0x1A,0x0E, 0x1B,0x04, 0x17,0x02, 0x1A,0x03, 0x1A,0x03, 0x1A,0x0E, 0x1B,0x04, 0x1A,0x03, 0x19,0x03, 0x17,0x03, 0x16,0x03, 0x17,0x0D, 0x16,0x03, 0x17,0x03, 0x19,0x01, 0x19,0x03, 0x19,0x03, 0x1A,0x03, 0x1F,0x03, 0x1B,0x03, 0x1B,0x03, 0x1A,0x03, 0x17,0x0D, 0x16,0x03, 0x16,0x03, 0x16,0x03, 0x17,0x01, 0x17,0x03, 0x17,0x03, 0x19,0x03, 0x1A,0x02, 0x1A,0x02, 0x10,0x03, 0x17,0x0D, 0x16,0x03, 0x16,0x01, 0x17,0x03, 0x19,0x03, 0x19,0x03, 0x17,0x03, 0x19,0x03, 0x1F,0x02, 0x1B,0x03, 0x1A,0x03, 0x1A,0x0E, 0x1B,0x04, 0x17,0x02, 0x1A,0x03, 0x1A,0x03, 0x1A,0x0E, 0x1B,0x04, 0x17,0x16, 0x1A,0x03, 0x1A,0x03, 0x1A,0x0E, 0x1B,0x04, 0x1A,0x03, 0x19,0x03, 0x17,0x03, 0x16,0x03, 0x0F,0x02, 0x10,0x03, 0x15,0x00, 0x00,0x00 }; unsigned char code Music_Yesterday[]={ 0x15,0x03, 0x15,0x03, 0x16,0x03, 0x17,0x02, 0x19,0x02, 0x19,0x03, 0x17,0x03, 0x19,0x03, 0x17,0x03, 0x1A,0x02, 0x19,0x66, 0x17,0x02, 0x17,0x03, 0x19,0x03, 0x1A,0x02, 0x16,0x02, 0x17,0x03, 0x19,0x02, 0x1A,0x15, 0x17,0x03, 0x19,0x03, 0x1A,0x02, 0x21,0x02, 0x20,0x03, 0x1F,0x02, 0x1B,0x03, 0x1B,0x66, 0x19,0x03, 0x17,0x03, 0x19,0x02, 0x17,0x02, 0x16,0x14, 0x15,0x03, 0x15,0x03, 0x16,0x03, 0x17,0x03, 0x19,0x02, 0x19,0x03, 0x19,0x03, 0x17,0x03, 0x19,0x03, 0x17,0x03, 0x1A,0x03, 0x19,0x02, 0x17,0x03, 0x17,0x02, 0x17,0x03, 0x19,0x03, 0x1A,0x02, 0x1B,0x02, 0x17,0x03, 0x19,0x02, 0x1A,0x03, 0x1A,0x01, 0x1B,0x02, 0x20,0x02, 0x1F,0x03, 0x1B,0x03, 0x1A,0x66, 0x1B,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x02, 0x1A,0x66, 0x1A,0x03, 0x1B,0x03, 0x1F,0x02, 0x1F,0x02, 0x1A,0x03, 0x1F,0x02, 0x20,0x03, 0x20,0x16, 0x1F,0x02, 0x20,0x02, 0x21,0x03, 0x21,0x03, 0x21,0x03, 0x21,0x02, 0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x03, 0x1A,0x66, 0x17,0x03, 0x19,0x03, 0x19,0x14, 0x1F,0x03, 0x20,0x03, 0x21,0x03, 0x21,0x03, 0x21,0x03, 0x21,0x03, 0x21,0x02, 0x20,0x03, 0x1F,0x03, 0x1F,0x03, 0x1B,0x03, 0x1A,0x66, 0x17,0x03, 0x19,0x03, 0x19,0x14, 0x1A,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x20,0x66, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x02, 0x1F,0x03, 0x20,0x66, 0x1F,0x03, 0x20,0x03, 0x21,0x02, 0x21,0x02, 0x20,0x03, 0x1F,0x02, 0x1A,0x03, 0x1A,0x02, 0x17,0x02, 0x17,0x03, 0x1A,0x03, 0x17,0x03, 0x19,0x03, 0x19,0x14, 0x17,0x03, 0x17,0x03, 0x16,0x04, 0x15,0x04, 0x15,0x03, 0x16,0x03, 0x17,0x01, 0x17,0x03, 0x18,0x02, 0x16,0x03, 0x16,0x14, 0x17,0x03, 0x17,0x03, 0x17,0x03, 0x18,0x02, 0x16,0x03, 0x16,0x16, 0x15,0x03, 0x16,0x03, 0x17,0x03, 0x16,0x01, 0x1F,0x02, 0x20,0x02, 0x21,0x03, 0x21,0x03, 0x21,0x03, 0x21,0x02, 0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x03, 0x1A,0x03, 0x1A,0x02, 0x17,0x03, 0x19,0x03, 0x19,0x14, 0x1F,0x02, 0x20,0x02, 0x21,0x03, 0x21,0x03, 0x21,0x03, 0x21,0x66, 0x20,0x03, 0x1F,0x03, 0x1B,0x03, 0x1F,0x03, 0x1B,0x03, 0x1A,0x66, 0x17,0x03, 0x19,0x03, 0x19,0x00, 0x00,0x00 }; uchar k; void delay1(void) //延时程序 { uchar i,j; for(i=20;i>0;i--) for(j=248;j>0;j--); } void Getch ( ) { uchar X,Y,Z; P1=0xff; P1=0xf3; //先对P0置数 行扫描 if(P1!=0xf3) //判断是否有键按下 { delay1(); //延时,软件去干扰 if(P1!=0xf3) //确认按键按下X = P3; { X=P1; //保存行扫描时有键按下时状态 P1=0xfc; //列扫描 Y=P1; //保存列扫描时有键按下时状态 Z=X|Y; //取出键值 switch ( Z ) //判断键值(那一个键按下) { case 0xf9: k=0; break; //对键值赋值 case 0xf5: k=1; break; case 0xfa: k=2; break;
上一篇:51单片机自动售水机程序
下一篇:两路电机驱动 H桥L9110
推荐阅读最新更新时间:2024-11-16 20:49
设计资源 培训 开发板 精华推荐
- AZ432精密2.5V/1A稳压器典型应用
- 相位/串行输入2相步进电机驱动IC —— TB67S213FTAG
- LT1085CT-5、5V/7.5A LDO 稳压器的典型应用电路
- 用于低压轨的 NCP456R 2A 单负载开关的典型应用电路,Vbias 连接至 IN 且无栅极延迟
- LTM8067IY 15V 浮动 1GBT 栅极驱动器的典型应用电路
- AD8604DRUZ 作为 DAC 输出缓冲器驱动重负载的典型应用
- AD9522-5/PCBZ,基于 AD9522-5 的评估板,12 LVDS/24 CMOS 输出时钟发生器
- 电赛源码 新型故障器
- 使用 ON Semiconductor 的 SPT7850 的参考设计
- 具有板载 ADC 和 I2C 的 LTC2945CMS-1 功率监视器的典型应用
- Allegro MicroSystems 在 2024 年德国慕尼黑电子展上推出先进的磁性和电感式位置感测解决方案
- 左手车钥匙,右手活体检测雷达,UWB上车势在必行!
- 狂飙十年,国产CIS挤上牌桌
- 神盾短刀电池+雷神EM-i超级电混,吉利新能源甩出了两张“王炸”
- 浅谈功能安全之故障(fault),错误(error),失效(failure)
- 智能汽车2.0周期,这几大核心产业链迎来重大机会!
- 美日研发新型电池,宁德时代面临挑战?中国新能源电池产业如何应对?
- Rambus推出业界首款HBM 4控制器IP:背后有哪些技术细节?
- 村田推出高精度汽车用6轴惯性传感器
- 福特获得预充电报警专利 有助于节约成本和应对紧急情况