课程设计c51单片机音乐演奏器设计制作~~用汇偏编的
- 提问者网友:沉默菋噵
- 2021-12-23 21:53
- 五星知识达人网友:平生事
- 2021-12-23 22:18
- 1楼网友:痴妹与他
- 2021-12-23 23:10
这么大的工程量,又没有积分,恐怕真是没有人来回答了,不过我原来倒是写了一个我的板子的音乐程序,你改改也许能用得上你的那个8键功能。 #include <reg51.h> sbit speaker=p3^6; unsigned char timer0h,timer0l,time,led=1,j=0; unsigned char flagd=0; //世上只有妈妈好数据表 code unsigned char sszymmh[]={ 6,2,3, 5,2,1, 3,2,2, 5,2,2, 1,3,2, 6,2,1, 5,2,1, 6,2,4, 3,2,2, 5,2,1, 6,2,1, 5,2,2, 3,2,2, 1,2,1, 6,1,1, 5,2,1, 3,2,1, 2,2,4, 2,2,3, 3,2,1, 5,2,2, 5,2,1, 6,2,1, 3,2,2, 2,2,2, 1,2,4, 5,2,3, 3,2,1, 2,2,1, 1,2,1, 6,1,1, 1,2,1, 5,1,6, 0,0,0 } ; // 音阶频率表 高八位 code unsigned char freqh[]={ 0xf2,0xf3,0xf5,0xf5,0xf6,0xf7,0xf8, 0xf9,0xf9,0xfa,0xfa,0xfb,0xfb,0xfc,0xfc, //1,2,3,4,5,6,7,8,i 0xfc,0xfd,0xfd,0xfd,0xfd,0xfe, 0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xff, } ; // 音阶频率表 低八位 code unsigned char freql[]={ 0x42,0xc1,0x17,0xb6,0xd0,0xd1,0xb6, 0x21,0xe1,0x8c,0xd8,0x68,0xe9,0x5b,0x8f, //1,2,3,4,5,6,7,8,i 0xee,0x44, 0x6b,0xb4,0xf4,0x2d, 0x47,0x77,0xa2,0xb6,0xda,0xfa,0x16, }; void delay(unsigned char t) { unsigned char t1; unsigned long t2; for(t1=0;t1<t;t1++) { for(t2=0;t2<6000;t2++) { ; } } tr0=0; } void t0int() interrupt 1 { tr0=0; speaker=!speaker; th0=timer0h; tl0=timer0l; tr0=1; }