help please

this is my code

int botones[6];
int botones[0] = 2;

int notas = {262,294,330,349};

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
int ValorTeclaPulsada = analogRead(A0);
Serial.println(ValorTeclaPulsada);
if(ValorTeclaPulsada == 1023){
tone(8, notas[0]);}
else if(ValorTeclaPulsada >= 990 && ValorTeclaPulsada <= 1010){
tone(8, notas[1]);
}
else if(ValorTeclaPulsada >= 505 && ValorTeclaPulsada <= 515){
tone(8, notas[2]);
}
else if(ValorTeclaPulsada >= 5 && ValorTeclaPulsada <= 10){
tone(8, notas[3]);
}
else{
noTone(8);
}
}

and this is the error

piano:2: error: conflicting declaration ‘int botones [0]’

int botones[0] = 2;

^

C:\Users\x\Desktop\arduino0\piano\piano.ino:1:5: note: previous declaration as ‘int botones [6]’

int botones[6];

^

exit status 1
conflicting declaration ‘int botones [0]’

There are four problems.

  1. Not reading the sticky post on how to post to the forum.
  2. Not using code tags which is covered in #1 (which makes the post horrible to read)
  3. Vague post title, over which most people will pass
  4. The program problem which is:

The statement

int botones[6];

declares an array of six integers.

The statement

int botones[0] = 2;

declares and array of 1 integer and sets the values of the first element to 2.

Problem is both have the same name.

Likely what you want is to declare the array of six integers and then set the first one to a value of 2. If that is the case then delete the redundant declaration "int botones[0] = 2;" and add the statement "botones[0] = 2;" into the setup routine.

yes that is the case and your solution dont work now thats the problem

piano:2: error: 'botones' does not name a type

botones[0] = 2;

^

exit status 1 'botones' does not name a type

Do your array initializing in one line.

Are you sure you are placing the line in the setup() routine or between the setup() and loop() routines?

Because what I posted works for everyone else. Please post new code using code tags.

mohammed77: yes that is the case and your solution dont work

Yes it does.

I suspect you didn't put botones[0] = 2; in setup as adwsystems told you to, but left it at the top.

im newbie so

i¨m so sorry because i didnt read the rules to post, and i will do, just sorry

i change “int botones [0]= 2” to “botones [0]= 2”

this is the code

int botones[6];
botones[0] = 2;

int notas = {262,294,330,349};

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
int ValorTeclaPulsada = analogRead(A0);
Serial.println(ValorTeclaPulsada);
if(ValorTeclaPulsada == 1023){
tone(8, notas[0]);}
else if(ValorTeclaPulsada >= 990 && ValorTeclaPulsada <= 1010){
tone(8, notas[1]);
}
else if(ValorTeclaPulsada >= 505 && ValorTeclaPulsada <= 515){
tone(8, notas[2]);
}
else if(ValorTeclaPulsada >= 5 && ValorTeclaPulsada <= 10){
tone(8, notas[3]);
}
else{
noTone(8);
}
}

and here is the new error

piano:2: error: ‘botones’ does not name a type

botones[0] = 2;

^

exit status 1
‘botones’ does not name a type

Listen to the people who are trying to help.

Move botones[0] = 2; into setup().

Put this line:

botones[0] = 2;

… in setup();

int notas[] = {262,294,330,349};

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
botones[0] = 2; // here <<<<<<<<<<<<<<<<<<<<<<
}

it s work correctly

thank you so much, i go to read the rules of the forum , im so sorry for my fault