Facing code error

I am facing this issue
is there someone who can do for me or help me to fix this error
I have tried my best but couldn't able to do fix.

Sorry, it seems like your code has some errors.
Close
In function 'void setup()':
13:5: error: a function-definition is not allowed here before '{' token
41:61: error: expected '}' at end of input
41:61: error: expected '}' at end of input
21:7: error: a function-definition is not allowed here before '{' token
41:61: error: expected '}' at end of input

int ledPins[ ]={3,4,5,6,7,8,9,10,11,12};
void setup()
{
for(int i =0; i <11; i++)
{
pinMode(Pins[i],OUTPUT);
}
{
void setup()
{
for (int i=0; i <11; i++)
{
pinMode(ledPins[i],OUTPUT);
}
}
{
void loop()
{
int i =10;
while (i<10)

        i++}

Please anyone help me

int ledPins={3,4,5,6,7,8,9,10,11,12};
void setup()

That won’t work, and you can’t have two setup() functions.

Further down, you have curly braces all over the place - use the auto-format tool, and in your next post, use CODE TAGS

@rogerscullan, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

Please edit your opening post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

This will e.g. prevent int ledPins[]={3,4,5,6,7,8,9,10,11,12} from being translated to int ledPins[]={3,4,5,6,7,8,9,10,11,12} .

You put void() function definition inside void() function. You cannot define function inside a function (except lambdas) this is a what the error tells you.

use </> to post code and error msgs

consider

#define N_LED  10
int ledPins [N_LED] ={3,4,5,6,7,8,9,10,11,12};

void setup ()
{
    for (int i =0; i <N_LED; i++)
    {
        pinMode (ledPins[i], OUTPUT);
    }
}

void loop ()
{
    // suggested operation
    for (int i =0; i <N_LED; i++)
    {
        digitalWrite (ledPins[i], ! digitalRead (ledPins[i]));
        delay (250);
    }
}

Your code is not complete; as the last line states, you're missing one (or more) } at the end.

Did you read the replies? Something you don't understand?

Start by auto-formatting the code (tools -> autoformat in the IDE); than it will look like below

int ledPins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
void setup()
{
  for (int i = 0; i < 11; i++)
  {
    pinMode(Pins[i], OUTPUT);
  }
  {
    void setup()
    {
      for (int i = 0; i < 11; i++)
      {
        pinMode(ledPins[i], OUTPUT);
      }
    }
    {
      void loop()
      {
        int i = 10;
        while (i < 10)

          i++
        }

Every function should start at the beginning of a line after an auto-format. Look at line 9 (the second void setup()), it does not start at the beginning of a line. That is because in the line before it, you used { instead of }. The same applies to the line with *void loop(); however, in that case the { before that line should not be there.

After fixing that and an autoformat, your code will look like

int ledPins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
void setup()
{
  for (int i = 0; i < 11; i++)
  {
    pinMode(Pins[i], OUTPUT);
  }
}
void setup()
{
  for (int i = 0; i < 11; i++)
  {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop()
{
  int i = 10;
  while (i < 10)

    i++
  }

The end of a function should have a } on the first position of a line after an autoformat. That that did not happen is because the line i++ is missing the semi-colon to close the statement.

After that, have a look at post #2 stating that you can't have two setup() functions.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.