⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yinyue.c

📁 用51单片机实现电子琴及mp3播放功能
💻 C
📖 第 1 页 / 共 3 页
字号:
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;//P3_0清"0",防止接蜂鸣器时继续发声,保证在接蜂鸣器时也静音;
}

void L12()//录音低音ra;
{
	int j;
	P3=0xe2;//显示"L2";
	P2=0x24;
	while(P1_1==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=LL2;//装载低音ra频率初值;
			TH0=LH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=LH2;
		plu=plu+1;
		*plu=LL2;
		*pdeng=0xe2;
		pdeng=pdeng+1;
		*pdeng=0x24;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;	
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L13()//录音低音mi;
{
	int j;
	P3=0xe2;//显示"L3";
	P2=0x0c;
	while(P1_2==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=LL3;//装载低音mi频率初值;
			TH0=LH3;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=LH3;
		plu=plu+1;
		*plu=LL3;
		*pdeng=0xe2;
		pdeng=pdeng+1;
		*pdeng=0x0c;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L14()//录音低音fa;
{
	int j;
	P3=0xe2;//显示"L4";
	P2=0x98;
	while(P1_3==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=LL4;//装载低音fa频率初值;
			TH0=LH4;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=LH4;
		plu=plu+1;
		*plu=LL4;
		*pdeng=0xe2;
		pdeng=pdeng+1;
		*pdeng=0x98;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L21()//录音低音so;
{
	int j;
	P3=0xe2;//显示"L5";
	P2=0x48;
	while(P1_0==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=LL5;//装载低音so频率初值;
			TH0=LH4;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=LH4;
		plu=plu+1;
		*plu=LL5;
		*pdeng=0xe2;
		pdeng=pdeng+1;
		*pdeng=0x48;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L22()//录音低音la;
{
	int j;
	P3=0xe2;//显示"L6";
	P2=0x40;
	while(P1_1==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=LL6;//装载低音la频率初值;
			TH0=LH6;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=LH6;
		plu=plu+1;
		*plu=LL6;
		*pdeng=0xe2;
		pdeng=pdeng+1;
		*pdeng=0x40;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L23()//录音低音si;
{
	int j;
	P3=0xe2;//显示"L7";
	P2=0x1e;
	while(P1_2==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=LL7;//装载低音si频率初值;
			TH0=LH7;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=LH7;
		plu=plu+1;
		*plu=LL7;
		*pdeng=0xe2;
		pdeng=pdeng+1;
		*pdeng=0x1e;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}
/////////////////////////////////////////////////////////////////////////////////
void L31()//录音中音do;
{
	int j;
	P3=0x84;//显示"d1";
	P2=0x9e;
	while(P1_0==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL1;//装载中音do频率初值;
			TH0=DH1;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH1;
		plu=plu+1;
		*plu=DL1;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x9e;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L32()//录音中音ra;
{
	int j;
	P3=0x84;//显示"d2";
	P2=0x24;
	while(P1_1==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL2;//装载中音ra频率初值;
			TH0=DH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH2;
		plu=plu+1;
		*plu=DL2;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x24;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L33()//录音中音mi;
{
	int j;
	P3=0x84;//显示"d3";
	P2=0x0c;
	while(P1_2==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL3;//装载中音mi频率初值;
			TH0=DH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH2;
		plu=plu+1;
		*plu=DL3;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x0c;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L34()//录音中音fa;
{
	int j;
	P3=0x84;//显示"d4";
	P2=0x98;
	while(P1_3==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL4;//装载中音fa频率初值;
			TH0=DH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH2;
		plu=plu+1;
		*plu=DL4;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x98;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L41()//录音中音so;
{
	int j;
	P3=0x84;//显示"d5";
	P2=0x48;
	while(P1_0==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL5;//装载中音so频率初值;
			TH0=DH5;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH5;
		plu=plu+1;
		*plu=DL5;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x48;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L42()//录音中音la;
{
	int j;
	P3=0x84;//显示"d6";
	P2=0x40;
	while(P1_1==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL6;//装载中音la频率初值;
			TH0=DH5;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH5;
		plu=plu+1;
		*plu=DL6;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x40;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L43()//录音中音si;
{
	int j;
	P3=0x84;//显示"d7";
	P2=0x1e;
	while(P1_2==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=DL7;//装载中音si频率初值;
			TH0=DH7;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH7;
		plu=plu+1;
		*plu=DL7;
		*pdeng=0x84;
		pdeng=pdeng+1;
		*pdeng=0x1e;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}
/////////////////////////////////////////////////////////////////////////////////
void L51()//录音高音do;
{
	int j;
	P3=0x90;//显示"H1";
	P2=0x9e;
	while(P1_0==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL1;//装载高音do频率初值;
			TH0=DH7;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=DH7;
		plu=plu+1;
		*plu=HL1;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x9e;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L52()//录音高音ra;
{
	int j;
	P3=0x90;//显示"H2";
	P2=0x24;
	while(P1_1==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL2;//装载高音ra频率初值;
			TH0=HH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=HH2;
		plu=plu+1;
		*plu=HL2;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x24;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L53()//录音高音mi;
{
	int j;
	P3=0x90;//显示"H3";
	P2=0x0c;
	while(P1_2==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL3;//装载高音mi频率初值;
			TH0=HH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=HH2;
		plu=plu+1;
		*plu=HL3;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x0c;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L54()//录音高音fa;
{
	int j;
	P3=0x90;//显示"H4";
	P2=0x98;
	while(P1_3==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL4;//装载高音fa频率初值;
			TH0=HH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=HH2;
		plu=plu+1;
		*plu=HL4;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x98;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L61()//录音高音so;
{
	int j;
	P3=0x90;//显示"H5";
	P2=0x48;
	while(P1_0==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL5;//装载高音so频率初值;
			TH0=HH2;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=HH2;
		plu=plu+1;
		*plu=HL5;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x48;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L62()//录音高音la;
{
	int j;
	P3=0x90;//显示"H6";
	P2=0x40;
	while(P1_1==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL6;//装载高音la频率初值;
			TH0=HH6;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=HH6;
		plu=plu+1;
		*plu=HL6;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x40;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

void L63()//录音高音si;
{
	int j;
	P3=0x90;//显示"H7";
	P2=0x1e;
	while(P1_2==0)//没有释放按键,继续录音;	
	{
		for(j=0;j<=5000;j=j+1)
		{
			TL0=HL7;//装载高音si频率初值;
			TH0=HH6;
			TR0=1;//启动T0;
			while(!TF0);
			P3_0=!P3_0;
			TF0=0;
		}
	}
		*plu=HH6;
		plu=plu+1;
		*plu=HL7;
		*pdeng=0x90;
		pdeng=pdeng+1;
		*pdeng=0x1e;
		lengthlu=lengthlu+2;
		lengthdeng=lengthdeng+2;
	plu=plu+1;
	pdeng=pdeng+1;
	P3=0xff;//灭灯;
	P2=0xff;
	P3_0=0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -