#define Do 495 #define Re 556 #define Mi 624 #define Fa 661 #define Sol 742 #define La 833 #define Si 935 #define hDo 990 #define hRe 1112 #define hMi 1178 #define hFa 1322 #define hSol 1484 #define hLa 1665 #define hSi 1869 #define dDo 248 #define dRe 278 #define dMi 294 #define dFa 330 #define dSol 371 #define dLa 416 #define dSi 467 int pin=12; //自行选择作为输出的接口 int scale[]={Do,Re,Mi,Fa,Sol,La,Si,dDo,dRe,dMi,dFa,dSol,dLa,dSi,hDo,hRe,hMi,hFa,hSol,hLa,hSi}; int pu[100]={1,3,5,6,5,5,5,5,1,1,3,3,100,100,1,3,4,6,5,5,5,5,4,4,3,3,100,100,1,3,5,6,5,5,5,5,4,4,3,3,2,2,1,1,100,1,1,1,1,2,3,2,2,100,100}; void setup(){ pinMode(pin,OUTPUT); } void loop(){ for(int i=0;i<61;i++){ if(pu[i]!=100) { tone(pin,scale[pu[i]-1]); } else noTone(pin); delay(200); noTone(pin); delay(100); } delay(5000); }
B调——小宇