music.c

来自「用KEILC写的单片机典型C51编程」· C语言 代码 · 共 46 行

C
46
字号

#include<reg51.h>
#include<define.h>
#include<global.h>
#include<initial.h>
#include<delay.h>
#include<led.h>
#include<input.h>
#include<beep.h>
#include<key.h>
#include<music.h>

byte code SOUNDLONG[ ] = 
{
	12,12,12,12,12,12,12,
	12,12,12,12,12,12,12,12
};
byte code	SOUNDTONE[] =
{
	3,188,3,83,2,246,2,204,2,125,2,56,1,250,
	1,221,1,169,1,123,1,101,1,28,0,253,0,258
};
void Music(byte count)
{
	byte i,k,j,SoundLong;
	word m,SoundTone;
	for(k=0;k<count;k++)
  {
	for(i=0;i<15;i++)
	{
		SoundLong = SOUNDLONG[i];
		SoundTone = SOUNDTONE[i*2]<<2;
		SoundTone+=SOUNDTONE[i*2+1];
		for(j=0;j<SoundLong;j++)
		{
			for(m=0;m<SoundTone;m++)
			P1_6=0;
			for(m=0;m<SoundTone;m++)
			P1_6=1;
		}
		DelayX10ms(50);
	}
	DelayX10ms(300);
	}
}

⌨️ 快捷键说明

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