noob programming help

Hey guys,

My name is phil and i’m a complete noob to arduino’s and micro controllers, well electronics as a whole to be fair.

I have been making my way through an ardx experimental kit and i’m having trouble with the following code http://ardx.org/src/circ/CIRC02-code.txt . I have been trying to get this code to light 8 LED’s in a sequence starting from the middle but whenever i try to compile it i get a few errors. I was hoping some more experinced guys could have a look and tell me where i went wrong?

int ledPins[] = {2,3,4,5,6,7,8,9};

void setup()
{
  for(int i = 0; i < 8; i++){
    pinMode (ledPins[i],OUTPUT);
  }
  
  void loop()
  {
    inAndOut(){
      int delayTime = 200;
      for(int i = 0; <=3; i++){
        int offLED = i -1;
        if(i == 0){
          offLED = 3;
        }
        
       int onLED1 = 3 - i;
       int onLED2 = 4 - i;
       
       int offLED1 = 3 - offLED;
       int offLED2 = 4 - offLED;
       
       digitalWrite(ledPins[onLED1], HIGH);
       digitalWrite(ledPins[onLED2], HIGH);
        digitalWrite(ledPins[offLED1], LOW);
        digitalWrite(ledPins[offLED2], LOW);
        delay (delayTime);
      }

Thanks so much guys
phil

My name is phil and i'm a complete noob

Welcome to complete noobs anonymous, phil.

tell me where i went wrong?

Well, the first thing you did was to post your code incorrectly. When posting code, use the # button before pasting code. Or, paste the code, then select it and press the # button. Tags are added that put the code in a scrollable box AND prevent the forum software from interpreting stuff in the code as forum software directives.

Look at the code you posted. See stuff missing, like [ i ] in lots of places? You are trying to define a function (inAndOut()) inside a function (loop()). That is not allowed.

Also, trying to declare a function called "loop" inside "setup" isn't allowed.

thanks for the help guys, i will get another look at it but i think ill have to start at the start again.

but i think ill have to start at the start again.

That would be one approach. The other would be making sure functions are not nested.

void setup()
{
}

void loop()
{
}

void inAndOut()
{
}