Why am I getting this error: " 'duration' was not declared in this scope "?
here code:
code: [select]
int piezo=2;
void play(int songid){
float bpms = 315.78;
int a=0;
int b=0;
int tones[]={261,294,329,349,392,440,493};
char notenames[]={'c','d','e','f','g','a','b'};
switch(songid){
case 1:
{float beat[]={1,1,2,1,1,2,1,1,1.5,0.5,4,1,1,1.5,0.5,1,1,0.5,0.5,1,1,1,1,2,2,1,1,2,1,1,2,1,1,1.5,0.5,4,1,1,1,1,1,1,1,0.5,0.5,1,1,1,1,4};
char notes[]={'e','e','e','e','e','e','e','g','c','d','e',' ','f','f','f','f','f','e','e','e','e','e','d','d','e','d','g','f','f','f','f','f','e','e','e','e','f','f','f','f','f','e','e','e','e','f','f','f','f','f','e','e','e','e','f','f','f','f','f','e','e','e','e','g','g','f','d','c'};
int duration= 51;
int tempo=190;
break;}
case 2:
{int beat[]={};
char notes[]={};
break;}
case 3:
{int beat[]={};
char notes={};
break;}
}
while(b<duration){
if(notes[b] == notenames[a]){
tone(piezo,tones[a],beat[b]*bpms);
b++;
a=0;
}
else{
a++;
}
}
}
void setup{
pinmode(piezo,output);
}
void loop{
play(1);
}
do favor:
1.) format code (your code hard read)
2.) initialize of variables @ beginning of function definition before processing
1.) format code (your code hard read)
2.) initialize of variables @ beginning of function definition before processing
Arduino Forum > Using Arduino > Programming Questions > Why am I getting this error: " 'duration' was not declared in this scope "?
arduino
Comments
Post a Comment