Solution for: exit status 1 expected '(' before '{' token

I came across this error while entering codes for a paper vending machine, any help or solutions for this one?

I also attached an image for the error.

Here is the code:

 int motor1 = 2;
int motor2 = 3;
int coinPin = 4;
int button1 = 5;
int button2 = 6;
int val;
int coinCount = 0;
int buttonState = 0;

void setup() {
   pinMode(motor1, OUTPUT);
   pinMode(motor2, OUTPUT);
   pinMode(button1, INPUT);
   pinMode(button2, INPUT);
   pinMode(coinPin, INPUT);
      }

void loop() {


      val = digitalRead(coinPin);
       if (val == HIGH) 
         {
            coinCount++;

             buttonState = digitalRead(button1);
              if (buttonState == HIGH && coinCount == 1) 
          { 
                
                 digitalWrite(motor1, HIGH);
                    delay(5000);
                                      digitalWrite(motor1, LOW);
                                           coinCount = 0;
                 }   
             else if
         { 
                   buttonState = digitalRead(button2);
                    if (buttonState == HIGH && coinCount == 1) 
          {
             pinMode(motor2, OUTPUT);
                        digitalWrite(motor2, HIGH);
                        delay(5000);
                       digitalWrite(motor2, LOW);
                       coinCount = 0;

             }  
          }


                 }

            }[left][/left]

else if   // line 32

The syntax for else if requires a comparison of some sort like, else if(something != somethingElse). If you are not doing a comparison, just use else.

Please fix your formatting. Autoformat (ctrl-t) would help a lot.

Hi,
Can you press CTRL-T in the IDE to auto format your code to make it easier to read?

Also it will align your { and } to see your code structure.

What is the code supposed to do?

Thanks.. Tom.. :slight_smile: