Error - Need help with - "a function-definition is not allowed here before '{' token"

Hi, when I run this code:

int leds[] = {2,3,4,5,6};
int ledsr[] = {6,5,4,3,2};
int i;
int j;
int k;
void setup() {
  // put your setup code here, to run once:
  for (i=0; i<5; i++){
    pinMode(leds[i],OUTPUT);
  }
}
void loop() {
  // put your main code here, to run repeatedly:
  void outwards();
  delay(200);
  void left();
  delay(200);
  void inwards();
  delay(200);
  void right();
  delay(200);
}
void left() {
  for (i=0; i<5; i++){
      digitalWrite(ledsr[i],HIGH);
      delay(100);
      digitalWrite(ledsr[i],LOW);
      delay(100);
    }
void outwards() {
  int i = 2;
  for (j=0; j<3; j++){
    digitalWrite(leds[i+j],HIGH);
    digitalWrite(leds[i-j],HIGH);
    delay(100);
    digitalWrite(leds[i+j],LOW);
    digitalWrite(leds[i-j],LOW);
    delay(100);
  }
}
void inwards() {
  int i = 0;
  int k = 4;
  for (j=0; j<3; j++){
    digitalWrite(leds[i+j],HIGH);
    digitalWrite(leds[k-j],HIGH);
    delay(100);
    digitalWrite(leds[i+j],LOW);
    digitalWrite(leds[k-j],LOW);
    delay(100);
  }
}
void right() {
  for (i=0; i<5; i++){
      digitalWrite(leds[i],HIGH);
      delay(100);
      digitalWrite(leds[i],LOW);
      delay(100);
    }
}

I Get these error codes:

C:\Users\victo\OneDrive - education.wa.edu.au\Files\School\Electronics\Arduino\project_4\project_4.ino: In function 'void left()':
project_4:30:17: error: a function-definition is not allowed here before '{' token
void outwards() {
^
project_4:41:16: error: a function-definition is not allowed here before '{' token
void inwards() {
^
project_4:53:14: error: a function-definition is not allowed here before '{' token
void right() {
^
project_4:60:1: error: expected '}' at end of input
}
^
exit status 1
a function-definition is not allowed here before '{' token

Help is much appreciated :grinning:

Auto-format your code with ctrl-t and you'll see the problem.

Just saw it I am such an idiot

Thx so much

At least I am not allone.

1 Like