I'm having many issues with this project.
First off, it says to make these global variables:
int buttons[6];
int buttons[0] = 2;
int notes[] = {262,294,330,349};
But, when I upload it gives me an error:
sketch_aug30a:2: error: conflicting declaration 'int buttons [0]'
sketch_aug30a:1: error: 'buttons' has a previous declaration as 'int buttons [6]'
The second thing is that even when I press the buttons connected to the Analog pin, nothing but "0" comes up on the serial monitor.
And lastly, no noise comes out.
Here's the code:
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);
}
}
It said since resistors are alway different, that I can use the serial monitor to check the values when buttons are pressed and use them for the code, but the only value I get is "0".
Help would be greatly appreciated. Thanks!