单片机声光电子琴程序流程图_单片机声光电子琴,含原理图,源代码(c代码),成品图…

  • Post author:
  • Post category:其他


/*

8个按键发出8个基本音,

能播放内置音乐,音乐跟随灯光闪烁

*/

#include

#define uint unsigned int

#define uchar unsigned char

sbit speaker=P1^4;//喇叭接30脚

sbit key1=P1^0;//流水灯按键(暂时)

sbit key2=P1^1;//播放音乐按键(暂定)

uchar a,b,num1,s1num,n1,n2;

uchar qushu=0;

char num;//定义num为可以负数

uchar code yinfu[]={0xfb,0xe9,      //Do

0xfc,0x5c,      //Re

0xfc,0xc1,      //Mi

0xfc,0xef,      //Fa

0xfd,0x45,      //So

0xfd,0x92,      //La

0xfd,0xd0,      //Si

0xfd,0xee,      //Do#

0x00,0x00,           //间隔

};

uchar code shengri_tone[]={   1,0,1,2,1,4,3,0, //生日快乐音调

1,0,1,2,1,5,4,0,

1,0,1,8,6,4,3,2,0,

7,0,7,6,4,5,4,0       //0代表不发声,即停顿;数字即为音调

};

uchar code laohu_tone[]={1,2,3,1,0,1,2,        //两只老虎乐谱 40个音符

3,1,0,3,4,5,0,3,

4,5,0,5,6,5,4,3,

1,0,5,6,5,4,3,1,

0,3,2,1,0,3,2,1,0

};

uchar code yishan_tone[]={1,1,5,5,6,6,5,        //星星乐谱  54个音符

0,4,4,3,3,2,2,

1,0,5,5,4,4,3,

3,2,0,5,5,4,4,

3,3,2,0,1,1,5,5,

6,6,5,0,4,4,3,

3,2,2,1,0

};

uchar code shengri_beat[]={   24,1,24,48,48,48,72,5,//节拍

24,1,24,48,48,48,72,5,

24,1,24,48,48,48,48,72,5,

24,1,24,48,48,48,72,5    //节拍,即tone表各音调的延时

};

uchar code laohu_beat[]={   24,24,24,4



版权声明:本文为weixin_39639096原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。