Project 07 - noTone not working

Hi,

I'm working on project 07 and although it's playing different notes, the last switch pressed keeps playing even after it's released. My understanding is that when no switches are pressed, the noTone command should turn the sound off.

Any help appreciated!

Code below:

int notes[]={262,294,330,349};
void setup() {
Serial.begin(9600);
}
void loop() {
int keyVal=analogRead(A0);
Serial.println(keyVal);
if(keyVal==1023){
tone(8,notes[0]);
}
else if (keyVal>=990 && keyVal<=1010){
tone(8,notes[1]);
}
else if (keyVal>=505 && keyVal<=515){
tone(8,notes[2]);
}
else if (keyVal>=5 && keyVal<=10){
tone(8,notes[3]);
}
else{
noTone[8];
}
}

I take it you didn't bother to read the the post 'How to use this forum'?

Double check the following line:  noTone[8];

Adjusting my original post to appease anyone offended by my forgetting to use on my first post in this forum.

Double checked and noTone[8]; is exactly what is in my Arduino code. Any suggestions on how to get it to stop playing the last key pressed would be great.

int notes[]={262,294,330,349};
void setup() {
Serial.begin(9600);
}
void loop() {
int keyVal=analogRead(A0);
Serial.println(keyVal);
if(keyVal==1023){
  tone(8,notes[0]);
}
else if (keyVal>=990 && keyVal<=1010){
  tone(8,notes[1]);
}
else if (keyVal>=505 && keyVal<=515){
  tone(8,notes[2]);
}
else if (keyVal>=5 && keyVal<=10){
  tone(8,notes[3]);
}
else{
  noTone[8];
}
}

Are you certain it's correct? Shouldn't it be noTone(8);?

https://www.arduino.cc/en/Reference/NoTone

noTone(8); instead of [] worked, thank you!

Now can you see why we like code tags? They don't change code to smileys, italics, bold, etc!

:smiley: