要求
控制蜂鸣器播放音乐
资源
工程文件压缩包 链接:https://pan.baidu.com/s/1hA-aa0JRP33IlOYFNzKf7A 提取码:0ida
main函数
#include <REGX52.H>
#include "Key.h"
#include "Delay.h"
#include "Nixie.h"
#include "MATRIXLED.H"
#include "Buzzer.h"
void main(){
unsigned char code context[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x08,0x10,0x10,0x10,0x0F,0x00,
0x00,0x5E,0x91,0xB1,0xA2,0x7F,0x01,0x00,0x81,0xFF,0x49,0x84,0x84,0x44,0x38,0x00,
0x81,0xFF,0x49,0x84,0x84,0x44,0x38,0x00,0x80,0xC1,0xB1,0x0F,0x0C,0xB0,0xC0,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x12,0x21,0x21,0x12,0x0C,0x00,0x00,0xD1,
0xDF,0x01,0x00,0x40,0x41,0x61,0x3F,0x41,0x41,0x60,0x00,0x00,0x20,0x20,0xFE,0x21,
0x21,0x02,0x00,0xFF,0x08,0x10,0x10,0x10,0x0F,0x00,0x1E,0x21,0x21,0x21,0x92,0xFF,
0x01,0x00,0x5E,0x91,0xB1,0xA2,0x7F,0x01,0x00,0x80,0xC1,0xB1,0x0F,0x0C,0xB0,0xC0,
0x80,0x00,0x00,0x00,0xFD,0x00,0x00,0xFD,0x00,0x00,0xFD,0x00,0x00,0x00,0x00,0x00};
unsigned char len0=128;
unsigned char i;
unsigned char counter=0;
unsigned char base=1;
unsigned char code Tune[]={5,5,6,5,1,7,0,5,5,6,5,2,1,0,5,5,5,3,1,7,6,0,4,4,3,1,2,1,0};
unsigned char code Tune_Interval[]={1,1,1,1,1,3,2,1,1,1,1,1,3,2,1,1,1,1,1,1,2,2,1,1,1,1,1,3,2};
unsigned int len=29;
unsigned int KEY;
while(1){
KEY=get_key();
if(KEY==1){
KEY=0;
for(i=0;i<len;i++){
Buzzer_Bass_Play(Tune_Interval[i]*80,Tune[i]);
KEY=get_key();
if(KEY==4){
break;
}
}
while(1){
for(i=0;i<8;i++){
MatrixLED_ShowColumn(i,context[base+i]);
}
counter++;
if(counter>14){
counter=0;
base++;
if(base>len0-8){
base=0;
}
}
if(base==0){
KEY=0;
break;
}
}
while(1){
MatrixLED_ShowColumn(0,0x70);
MatrixLED_ShowColumn(1,0x88);
MatrixLED_ShowColumn(2,0x84);
MatrixLED_ShowColumn(3,0x62);
MatrixLED_ShowColumn(4,0x62);
MatrixLED_ShowColumn(5,0x84);
MatrixLED_ShowColumn(6,0x88);
MatrixLED_ShowColumn(7,0x70);
KEY=get_key();
if(KEY==4){
break;
}
}
}
}
}
|