📄 yinyue.c
字号:
P3_0=0;
}
void k62()//高音la;
{
P3=0x90;
P2=0x40;
do
{
TL0=HL6;
TH0=HH6;
TR0=1;
while(!TF0);
P3_0=!P3_0;
TF0=0;
}
while(P1_1==0);
P3_0=0;
}
void k63()//高音si;
{
P3=0x90;
P2=0x1e;
do
{
TL0=HL7;
TH0=HH6;
TR0=1;
while(!TF0);
P3_0=!P3_0;
TF0=0;
}
while(P1_2==0);
P3=0xff;//灭灯;
P2=0xff;
P3_0=0;
}
/*************************************************/
/*****歌曲响*****/
void gequ()
{
int x;
int y;
// int z;
for(x=0;x<3;x=x+1)
{
P3=0xff;
P2=0xff;
for(y=0;y<=23000;y=y+1)
{
}
P3=0x00;//亮灯;
P2=0x00;
for(y=0;y<=32000;y=y+1)
{
}
}
while(1)//扫描选择功能键,选择播放模式;
{
P0=0xff;//I/O口置高电平,准备扫描键盘;
P1=0xff;
P0_1=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
model1();//选择单曲播放,播放完毕停止;
}
P0=0xff;
P1=0xff;
P0_3=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
model2();//选择单曲循环播放模式;
}
P0=0xff;
P1=0xff;
P0_5=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
model3();//选择全部循环播放模式;
}
}
}
/*************************************************/
/****播放模式****/
/*****模式 1*****/
void model1()//选择了单曲播放模式;
{
do//扫描歌曲键,选择播放曲目;
{
P3=0x12;//显示"n1",代表选择模式1;
P2=0x9e;
P0=0xff;//I/O口置高电平;
P1=0xff;
P0_1=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
gequ1();//选择1号歌曲;
}
P0=0xff;
P1=0xff;
P0_3=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
gequ2();//选择2号歌曲;
}
P0=0xff;
P1=0xff;
P0_5=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
gequ3();//选择3号歌曲;
}
}
while(1);
}
/*****模式 2*****/
void model2()//选择了单曲循环;
{
while(1)//扫描歌曲键;
{
P3=0x12;
P2=0x24;
P0=0xff;//I/O口置高电平;
P1=0xff;
P0_1=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
{
while(1)
{
gequ1();//选择1号歌曲;
}
}
}
P0=0xff;
P1=0xff;
P0_3=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
{
while(1)
{
gequ2();//选择2号歌曲;
}
}
}
P0=0xff;
P1=0xff;
P0_5=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
{
while(1)
{
gequ3();//选择3号歌曲;
}
}
}
}
}
/*****模式 3*****/
void model3()//选择了全部循环播放;
{
P3=0x12;
P2=0x0c;
while(1)
{
gequ1();
gequ2();
gequ3();
}
}
/****三首歌曲****/
/****1 号歌曲****/
void gequ1()
{
int i1;
char *pfreq1;
int j;
//int x;
/*
code unsigned char table[]={
1 2 3 4 5 6 7
LH1,LL1,LH2,LL2,LH3,LL3,LH4,LL4,LH4,LL5,LH6,LL6,LH7,LL7,
DH1,DL1,DH2,DL2,DH2,DL3,DH2,DL4,DH5,DL5,DH5,DL6,DH7,DL7,
DH7,HL1,HH2,HL2,HH2,HL3,HH2,HL4,HH2,HL5,HH6,HL6,HH6,HL7
};
*/
code unsigned char tablefreq1[]={
DH2,DL3,DH5,DL5,DH7,0x93,DH5,DL5,DH5,0xf7,DH5,0xf7,
DH5,0xf7,DH5,DL5,DH2,DL3,DH2,DL3,DH5,DL5,DH5,DL5,
DH2,DL3,DH5,DL5,DH5,0xf7,DH7,0x93,HH2,HL2,DH7,0x93,DH5,DL5,DH2,DL3,0xf9,0xf6,DH5,DL5,DH5,DL5,DH2,DL3,DH2,DL3,
DH2,DL3,DH5,DL5,DH7,0x93,DH5,DL5,DH5,0xf7,DH5,0xf7,
DH7,0x93,HH2,HL2,DH7,0x93,DH5,DL5,DH2,DL3,DH5,DL5,DH7,0x93,DH5,0xf7,DH5,0xf7,
DH2,DL3,0xf9,0xf6,DH2,DL3,DH5,DL5,HH2,0x49,HH2,HL2,HH2,HL2,DH7,0x93,DH7,0x93
};
P3=0x02;//显示"01",代表播放第1首歌曲;
P2=0x9e;
i1=100;
pfreq1=tablefreq1;
do
{
j=80;
do
{
TL1=0x00;
TH1=0x8c;
TR1=1;
do
{
TR0=0;
TH0=*pfreq1;
pfreq1=pfreq1+1;
TL0=*pfreq1;
TR0=1;
while(!TF0);
P3_0=!P3_0;
TF0=0;
pfreq1=pfreq1-1;
}
while(!TF1);
TF1=0;
j=j-1;
}
while(j>0);
TF0=0;
TF1=0;
pfreq1=pfreq1+2;
i1=i1-2;
}
while(i1>0);
P3=0xff;
P2=0xff;
}
/****2 号歌曲****/
void gequ2()
{
int i2;
char *pfreq2;
int j;
//int x;
code unsigned char tablefreq2[]={
0xf6,0xd3,0xf9,0x05,0xf9,0x05,0xfa,0x8a,0xfb,0x68,0xfb,0x68,0xf9,0x05,
0xf8,0xb6,0xf8,0xb6,0xfa,0x8a,0xfb,0x68,0xfb,0x68,
0xfb,0x68,0xfb,0xf7,0xfc,0x48,0xfc,0x48,0xfc,0x8a,0xfc,0x8a,
0xfb,0xf7,0xfb,0xf7,0xfb,0x68,0xfb,0x68,0xfb,0x68,
0xfa,0x8a,0xf9,0xf6,0xf9,0x05,0xf9,0x05,0xf9,0x05,
0xfa,0x8a,0xf9,0xf6,0xf9,0x05,0xf9,0x05,0xf9,0x05,
0xf9,0xf6,0xfa,0x8a,0xf9,0xf6,0xf9,0x05,0xf7,0xce,0xf7,0xce,
0xf9,0xf6,0xfa,0x8a,0xf9,0xf6,0xf9,0xf6
};
P3=0x02;
P2=0x24;
i2=86;
pfreq2=tablefreq2;
do
{
j=80;
do
{
TL1=0x00;
TH1=0x8c;
TR1=1;
do
{
TR0=0;
TH0=*pfreq2;
pfreq2=pfreq2+1;
TL0=*pfreq2;
TR0=1;
while(!TF0);
P3_0=!P3_0;
TF0=0;
pfreq2=pfreq2-1;
}
while(!TF1);
TF1=0;
j=j-1;
}
while(j>0);
TF0=0;
TF1=0;
pfreq2=pfreq2+2;
i2=i2-2;
}
while(i2>0);
P3=0xff;
P2=0xff;
}
/****3 号歌曲****/
void gequ3()
{
int i3;
char *pfreq3;
int j;
//int x;
code unsigned char tablefreq3[]={
0xf9,0x05,0xf9,0x05,0xf9,0xf6,0xf9,0xf6,0xfa,0x8a,0xfa,0x8a,0xf9,0x05,0xf9,0x05,
0xf9,0x05,0xf9,0x05,0xf9,0xf6,0xf9,0xf6,0xfa,0x8a,0xfa,0x8a,0xf9,0x05,0xf9,0x05,
0xfa,0x8a,0xfa,0x8a,0xfa,0xd8,0xfa,0xd8,0xfb,0x68,0xfb,0x68,
0xfa,0x8a,0xfa,0x8a,0xfa,0xd8,0xfa,0xd8,0xfb,0x68,0xfb,0x68,
0xfb,0x68,0xfb,0xf7,0xfb,0x68,0xfa,0xd8,0xfa,0x8a,0xfa,0x8a,0xf9,0x05,0xf9,0x05,
0xfb,0x68,0xfb,0xf7,0xfb,0x68,0xfa,0xd8,0xfa,0x8a,0xfa,0x8a,0xf9,0x05,0xf9,0x05,
0xf9,0x05,0xf9,0x05,0xf6,0xd3,0xf6,0xd3,0xf9,0x05,0xf9,0x05,
0xf9,0x05,0xf9,0x05,0xf6,0xd3,0xf6,0xd3,0xf9,0x05,0xf9,0x05
};
P3=0x02;
P2=0x0c;
i3=112;
pfreq3=tablefreq3;
do
{
j=70;
do
{
TL1=0x00;
TH1=0x8c;
TR1=1;
do
{
TR0=0;
TH0=*pfreq3;
pfreq3=pfreq3+1;
TL0=*pfreq3;
TR0=1;
while(!TF0);
P3_0=!P3_0;
TF0=0;
pfreq3=pfreq3-1;
}
while(!TF1);
TF1=0;
j=j-1;
}
while(j>0);
TF0=0;
TF1=0;
pfreq3=pfreq3+2;
i3=i3-2;
}
while(i3>0);
P3=0xff;
P2=0xff;
}
/*************************************************/
/******录音******/
void luyin()
{
while(1)
{
// int chonglu;
// chonglu=1;
lengthlu=0;
lengthdeng=0;
P3=0xff;
P2=0xff;
plu=tablelu;
pdeng=tabledeng;
P0=0xff;
P1=0xff;
P0_1=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
jianpanluyin();
}
}
}
void jianpanluyin()
{
int x;
int y;
for(x=0;x<3;x=x+1)
{
P3=0xff;
P2=0xff;
for(y=0;y<=23000;y=y+1)
{
}
P3=0x00;//亮灯;
P2=0x00;
for(y=0;y<=32000;y=y+1)
{
}
}
while(1)
{
/***扫描第一行***/
P0=0xff;
P1=0xff;
P0_0=0;//把第一行赋值0,逐列判断;
if(P1_0==0)//判断是否是第一列的被按下,是则跳转,不是则继续判断;
L11();
if(P1_1==0)//判断第二列;
L12();
if(P1_2==0)//判断第三列;
L13();
if(P1_3==0)//判断第四列;
L14();
/***扫描第二行***/
P0=0xff;
P1=0xff;
P0_1=0;//把第2行赋值0;
if(P1_0==0)
L21();
if(P1_1==0)
L22();
if(P1_2==0)
L23();
if(P1_3==0)
{
int j;
for(j=0;j<=15000;j=j+1)
{
}
if(P1_3==0)
break;//结束录音;
}
/***扫描第三行***/
P0=0xff;
P1=0xff;
P0_2=0;//把第3行赋值0;
if(P1_0==0)
L31();
if(P1_1==0)
L32();
if(P1_2==0)
L33();
if(P1_3==0)
L34();
/***扫描第四行***/
P0=0xff;
P1=0xff;
P0_3=0;//把第4行赋值0;
if(P1_0==0)
L41();
if(P1_1==0)
L42();
if(P1_2==0)
L43();
/***扫描第五行***/
P0=0xff;
P1=0xff;
P0_4=0;//把第5行赋值0;
if(P1_0==0)
L51();
if(P1_1==0)
L52();
if(P1_2==0)
L53();
if(P1_3==0)
L54();
/***扫描第六行***/
P0=0xff;
P1=0xff;
P0_5=0;//把第6行赋值0;
if(P1_0==0)
L61();
if(P1_1==0)
L62();
if(P1_2==0)
L63();
}
// int x;
// int y;
for(x=0;x<3;x=x+1)
{
P3=0xff;
P2=0xff;
for(y=0;y<=23000;y=y+1)
{
}
P3=0x00;//亮灯;
P2=0x00;
for(y=0;y<=32000;y=y+1)
{
}
}
while(1)
{
P0=0xff;
P1=0xff;
P0_3=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
bofang();//回放录音;
}
P0=0xff;
P1=0xff;
P0_5=0;
if(P1_3==0)
{
int j;
for(j=0;j<=23000;j=j+1)
{
}
if(P1_3==0)
luyin();//重新录音;
}
}
}
void bofang()
{
int x;
int y;
int i;
for(x=0;x<3;x=x+1)
{
P3=0xff;
P2=0xff;
for(y=0;y<=23000;y=y+1)
{
}
P3=0x00;//亮灯;
P2=0x00;
for(y=0;y<=32000;y=y+1)
{
}
}
// lengthlu=lengthlu;//记录数据长度;
// lengthdeng=lengthdeng;
plu=tablelu;
pdeng=tabledeng;
for(;lengthlu>0;lengthlu=lengthlu-2)
{
P3=*pdeng;
pdeng=pdeng+1;
P2=*pdeng;
pdeng=pdeng+1;
for(i=0;i<=5000;i=i+1)
{
TH0=*plu;
plu=plu+1;
TL0=*plu;
TR0=1;
while(!TF0);
P3_0=!P3_0;
TR0=0;
TF0=0;
plu=plu-1;
}
plu=plu+2;
}
for(x=0;x<3;x=x+1)
{
P3=0xff;
P2=0xff;
for(y=0;y<=23000;y=y+1)
{
}
P3=0x00;//亮灯;
P2=0x00;
for(y=0;y<=32000;y=y+1)
{
}
}
}
/////////////////////////////////////////////////////////////////////////////////
void L11()//录音低音do;
{
int j;
P3=0xe2;//显示"L1";
P2=0x9e;
while(P1_0==0)//没有释放按键,继续录音;
{
for(j=0;j<=5000;j=j+1)
{
TL0=LL1;//装载低音do频率初值;
TH0=LH1;
TR0=1;//启动T0;
while(!TF0);//当计时时间到时,TF0变为1,则停止计数;
P3_0=!P3_0;//P3_0翻转,实现输出规定频率的方波;
TF0=0;//清除标志位,准备下一次计数;
}
}
*plu=LH1;//把初值装入tablelu;
plu=plu+1;
*plu=LL1;
*pdeng=0xe2;//把灯的初值装入tabledeng;
pdeng=pdeng+1;
*pdeng=0x9e;
lengthlu=lengthlu+2;
lengthdeng=lengthdeng+2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -