Pages: [1]   Go Down
Author Topic: I can't figure out how to fix the error message. I have no idea how.  (Read 351 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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);
  }               
}
 
Logged

California
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3123
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Arrays are initialized with curly braces, not parentheses.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ohhh. thanks
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11197
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's no doubt that's the problem, but I must admit I find that error message quite enigmatic.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46267
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1]   Go Up
Jump to: