Go Down

Topic: I can't figure out how to fix the error message. I have no idea how. (Read 481 times) previous topic - next topic

lfahmy

I'm a beginner and don't have much "know-how" in programming. I tried to compile this code and load it onto my board, but received this error message which I didn't understand. The error is: initializer fails to determine size of 'ledPins'. It highlights the first line of the code. Any solutions? I don't know what it means by the "size" of the pins.



Code: [Select]


int ledPins[] = (2,3,4,5,6,7,8,9);

void setup()
{
  int index;

  for(index = 0; index <= 7; index++)
  {
    pinMode(ledPins[index], OUTPUT);
  }
}

void loop()
{
  int index;
  int delayTime = 2000;
 
  for(index = 0; index <= 7; index++)
  {
    digitalWrite(ledPins[index], HIGH);
    delay(delayTime);
  }
 
  for(index = 7; index >= 0; index--)
  {
    digitalWrite(ledPins[index], LOW);
    delay(delayTime);
  }               
}
 

Arrch

Arrays are initialized with curly braces, not parentheses.


PeterH

There's no doubt that's the problem, but I must admit I find that error message quite enigmatic.
I only provide help via the forum - please do not contact me for private consultancy.

PaulS

Quote
but I must admit I find that error message quite enigmatic.

The comma operator got applied to all the stuff in the parentheses. The result was not a list of initializers. How else should the message be worded?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy