initializer fails to determine size of 'leds'

Hello there... i have a problem with my code... but i dont know what is ... i take this code from a course ... and when i want to upload to arduino send me this masage that say "initializer fails to determine size of 'leds'"

i leave the code ... if u can help me ... will be greatfull

//variables

int leds[]=(4,6,7,8,9,10,11,12,13); int tiempoRet=400; void setup() { // put your setup code here, to run once: pinMode(leds[0],OUTPUT); pinMode(leds[1],OUTPUT); pinMode(leds[2],OUTPUT); pinMode(leds[3],OUTPUT); pinMode(leds[4],OUTPUT); pinMode(leds[5],OUTPUT); pinMode(leds[6],OUTPUT); pinMode(leds[7],OUTPUT); pinMode(leds[8],OUTPUT); pinMode(leds[9],OUTPUT); }

void loop() { // put your main code here, to run repeatedly: digitalWrite(leds[0],HIGH); digitalWrite(leds[1],HIGH); digitalWrite(leds[2],HIGH); digitalWrite(leds[3],HIGH); digitalWrite(leds[4],HIGH); digitalWrite(leds[5],HIGH); digitalWrite(leds[6],HIGH); digitalWrite(leds[7],HIGH); digitalWrite(leds[8],HIGH); digitalWrite(leds[9],HIGH); delay(tiempoRet);

digitalWrite(leads[0],LOW); digitalWrite(leads[1],LOW); digitalWrite(leads[2],LOW); digitalWrite(leads[3],LOW); digitalWrite(leads[4],LOW); digitalWrite(leads[5],LOW); digitalWrite(leads[6],LOW); digitalWrite(leads[7],LOW); digitalWrite(leads[8],LOW); digitalWrite(leads[9],LOW); delay(tiempoRet); }

juankiinwave:
Hello there… i have a problem with my code… but i dont know what is … i take this code from a course … and when i want to upload to arduino send me this masage that say
“initializer fails to determine size of ‘leds’”

i leave the code … if u can help me … will be greatfull

You should put your code listing inside the code tags (the </> button in the upper left corner of the editor).

//variables
 
int leds[]=(4,6,7,8,9,10,11,12,13);
int tiempoRet=400;
void setup() {
  // put your setup code here, to run once:
  pinMode(leds[0],OUTPUT);
  pinMode(leds[1],OUTPUT);
  pinMode(leds[2],OUTPUT);
  pinMode(leds[3],OUTPUT);
  pinMode(leds[4],OUTPUT);
  pinMode(leds[5],OUTPUT);
  pinMode(leds[6],OUTPUT);
  pinMode(leds[7],OUTPUT);
  pinMode(leds[8],OUTPUT);
  pinMode(leds[9],OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(leds[0],HIGH);
digitalWrite(leds[1],HIGH);
digitalWrite(leds[2],HIGH);
digitalWrite(leds[3],HIGH);
digitalWrite(leds[4],HIGH);
digitalWrite(leds[5],HIGH);
digitalWrite(leds[6],HIGH);
digitalWrite(leds[7],HIGH);
digitalWrite(leds[8],HIGH);
digitalWrite(leds[9],HIGH);
delay(tiempoRet);

digitalWrite(leads[0],LOW);
digitalWrite(leads[1],LOW);
digitalWrite(leads[2],LOW);
digitalWrite(leads[3],LOW);
digitalWrite(leads[4],LOW);
digitalWrite(leads[5],LOW);
digitalWrite(leads[6],LOW);
digitalWrite(leads[7],LOW);
digitalWrite(leads[8],LOW);
digitalWrite(leads[9],LOW);
delay(tiempoRet);
}

Anyway, this is your problem:

int leds[]=(4,6,7,8,9,10,11,12,13); // WRONG

You used parentheses. You should use braces:

int leds[]={ 4,6,7,8,9,10,11,12,13 }; // RIGHT

See the difference?

:o Ohhh man... yeah i saw them... Thnks a lot!! XD ... i will continue preacticing.. Bless

If tell this ... Arduino / Genuine Uno card compilation error is that my arduino is useless'??

Did the error came while uploading?

yess... Just when the load is completed

If some components are connected to the TX and RX pins(0,1), it might cause a problem with uploading

Possibly is that I only have 3 pins connected to his own led... because ai have only 3 leads on the protoboard ... {3,10,11}??

A compilation error occurs before the upload to the board. So that does not indicate that there is something wrong with your board.

Please post the content of the output window; we're interested in the part that is in orange.

After an error, there is usually a button 'copy error message' or something in that line. You can use that as well but it might be too large.

Also please post the your code that gave the error.

juankiinwave: Possibly is that I only have 3 pins connected to his own led... because ai have only 3 leads on the protoboard ... {3,10,11}??

Sorry, I didn't understand. If you have a doubt whether there is any problem with the Arduino, disconnect the components and try uploading any basic example program.

Thnks 4 the help... :)

//Here is the error mesage ..

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

exit status 1 Error compilación en tarjeta Arduino/Genuino Uno.

//This is the code..

/programa de encendido de leds Alto simple/

//variables

int leds[]={ 4,6,7,8,9,10,11,12,13 }; int tiempoRet=400; void setup() { // put your setup code here, to run once: pinMode(leds[0],OUTPUT); pinMode(leds[1],OUTPUT); pinMode(leds[2],OUTPUT); pinMode(leds[3],OUTPUT); pinMode(leds[4],OUTPUT); pinMode(leds[5],OUTPUT); pinMode(leds[6],OUTPUT); pinMode(leds[7],OUTPUT); pinMode(leds[8],OUTPUT); pinMode(leds[9],OUTPUT); }

void loop() { // put your main code here, to run repeatedly: digitalWrite(leds[0],HIGH); digitalWrite(leds[1],HIGH); digitalWrite(leds[2],HIGH); digitalWrite(leds[3],HIGH); digitalWrite(leds[4],HIGH); digitalWrite(leds[5],HIGH); digitalWrite(leds[6],HIGH); digitalWrite(leds[7],HIGH); digitalWrite(leds[8],HIGH); digitalWrite(leds[9],HIGH); delay(tiempoRet);

digitalWrite(leds[0],LOW); digitalWrite(leds[1],LOW); digitalWrite(leds[2],LOW); digitalWrite(leds[3],LOW); digitalWrite(leds[4],LOW); digitalWrite(leds[5],LOW); digitalWrite(leds[6],LOW); digitalWrite(leds[7],LOW); digitalWrite(leds[8],LOW); digitalWrite(leds[9],LOW); delay(tiempoRet); }

Grr - stupid bloody C comma operator. Yet another one of K&R's bad ideas: a hack to make it possible to jam multiple things in a for(;;) clause.

i dont catch it... ?? :/

I was able to successfully upload the program in my arduino. Did you try with all the components removed?

cooool its done ... i didnt saw that i put space inside the braces ... thnkss 4 ur hlp evrybdy","

PaulMurrayCbr: Grr - stupid bloody C comma operator. Yet another one of K&R's bad ideas: a hack to make it possible to jam multiple things in a for(;;) clause.

What on earth are you talking about?

juankiinwave: Thnks 4 the help... :)

//Here is the error mesage ..

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

You have 9 elements in your LED array, but you try to access 10 of them (led[0] through led[9]).

You only have led[0] thru led[8].