60: error: expected unqualified-id before 'else'

I'm getting this weird error, and in a weird place (line 60)

60: error: expected unqualified-id before 'else'

//#include <Wire.h>
#include <string.h>
#include <AFMotor.h>
//#include <utility\twi.h>
//#include <stdio.h>
#include <Servo.h>

#define HIGH true
#define LOW false

//Pins 0 & 1 is for Tx & RX for computer DO NOT PUT SERIAL THINGS (aka the BLUESMiRF RP-SMA) HERE OR CODE WILL NOT UPLOAD TO THE ARDUINO!!!    maybe.....
#define front_light_R         0
#define front_light_G         1
#define front_light_B         2

#define X_turret_servo        7
#define Y_turret_servo        8

#define steer_servo           11
#define drive_motor           12
#define debugled              13
//Pins 14 & 15 is for TX & RX for Bluetooth (Serial3)
//Pins 16 & 17 is for Tx & RX for GPS (Serial2)
//Pins 18 & 19 is UNKNOWN (Serial1)
//Pins 20 & 21 is SDA & SCL for I2C
#define top_check             22
#define buzzer                23
#define lazor                 24
#define head_lights           25
#define tail_lights           26
#define button                27
#define seg_display[]        [28,29,30,31,32,33,34,35] //A,B,C,D,E,F,G,RHDP

#define photo analogRead(0)
#define dip_switch analogRead(8)
#define TOP_CHECK digitalRead(top_check)

#define usb Serial
//#define CAM Serial1
//#define GPS Serial2
#define bluetooth Serial3

#define PHONE_IDLE    0
#define PHONE_RINGING 1
#define PHONE_OFFHOOK 2       <------it errors right here

long previousBLUETOOTHupdate = 0;
long previousBUTTONupdate    = 0;
long previousPULSEupdate     = 0;
long previousDEBUGupdate     = 0;
//long previousACCELupdate     = 0;
long previousBUZZupdate      = 0;
long previousGYROupdate      = 0;
long previousRGBupdate       = 0;

char PhoneinData[100];
char Phone_Flag;

int index = 0;
int phone_call_state = 0;
int phone_light = 0;
int phone_compass = 0;
int phone_gyro[3]; //Z:0-359-X:-180-180-Y:-90-90 
int previous_phone_gyro[3];  
int phone_accel[3]; //X-Y-Z
//int previous_phone_accel[3]; //X-Y-Z

boolean no_BLUETOOTH_com = false;
boolean no_USB_com = false;
boolean no_Amarino_com = false;
boolean debug = false;
boolean debuginit = false;
boolean button_state = false;
boolean started = false;
boolean ended = false;
boolean phones_screen_off = false;

Servo x_turret_servo;
Servo y_turret_servo;
Servo steer;

#ifdef drive_motor
  Servo drive;
#else
  AF_DCMotor drive(2);
#endif

void setup ()
{ 
  pinMode(button, INPUT);
  pinMode(top_check, INPUT);
  
  pinMode(debugled,OUTPUT);
  pinMode(lazor,OUTPUT);
  
  #ifdef drive_motor
    pinMode(drive_motor, OUTPUT);
  #endif
  
  pinMode(tail_lights, OUTPUT);
  pinMode(head_lights, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(front_light_R, OUTPUT);
  pinMode(front_light_G, OUTPUT);
  pinMode(front_light_B, OUTPUT);

  bluetooth.begin (57600);
  usb.begin (57600);

  delay(100);

  if (digitalRead(button) == HIGH)
  {
    // turn RED LED on:    
    digitalWrite(debugled, HIGH);  

    debuginit = true;
  }

  #ifdef drive_motor
     drive.attach(drive_motor,1000,2000); //this is special for the BareBone motor controller.
  #endif
  
  steer.attach(steer_servo);
  x_turret_servo.attach(X_turret_servo);
  y_turret_servo.attach(Y_turret_servo);
}
void loop ()
{  
  GET_PHONE_DATA();
  //debug_led_update();
  //head_light_updater();
  //tail_light_updater();
  //buzzer_updater(false);
  //button_updater();
  //RGB(abs(phone_gyro[2]),abs(phone_gyro[1]));
  
  usb.print(phone_gyro[0]);
  usb.print("; ");
  usb.print(phone_gyro[1]);
  usb.print("; ");
  usb.println(phone_gyro[2]);
  
  if (usb.available() > 0)
    no_USB_com = false;
  else
    no_USB_com = true;
  
  if (no_BLUETOOTH_com)// || !TOP_CHECK)
  {
    DRIVE(0);
    steer.write(65);
    x_turret_servo.write(90);
    y_turret_servo.write(90);
    
    digitalWrite(debugled,HIGH);
  }
  else
  {
    digitalWrite(debugled,LOW);
    
    x_turret_servo.write(map(phone_gyro[1],-180,180,0,180));
    y_turret_servo.write(map(phone_gyro[2],-90,90,30,180));
    
    if (!no_BLUETOOTH_com && phone_call_state == PHONE_IDLE)
    {
      DRIVE(phone_gyro[2]);
      steer.write(map(phone_gyro[1],45,-45,10,110));
    }
  }
}
void DRIVE(int power)
{
  #ifdef drive_motor
    if(power == phone_gyro[2] && phone_gyro[2]  > 47)
      drive.write(map(power,47,85,88,58));
    else if (power == phone_gyro[2] && phone_gyro [2] < 42)
      drive.write(map(power,42,0,92,122));
    else
      drive.write(90);
  #else
    if(power == 0)
      drive.setSpeed(0);
    else if(power > 0 && power <= 255)
    {
      drive.run(FORWARD);
      drive.setSpeed(power);
    )
    else if (power < 0 && power >= -255)
    {
      drive.run(BACKWARD);
      drive.setSpeed(-power);
    }
    else
      drive.setSpeed(0);
  #endif
}
void RGB (int R = 0, int G = 0, int B = 0)
{
  if (R >= 0 && R <= 255)
    analogWrite(front_light_R, R);
  if (G >= 0 && G <= 255)
    analogWrite(front_light_G, G);
  if (B >= 0 && B <= 255)
    analogWrite(front_light_B, B);
}
void debug_led_update()
{
  if (no_BLUETOOTH_com && (millis() - previousDEBUGupdate) > 500)
  {
    previousDEBUGupdate = millis();

    debug = !debug;
    digitalWrite (debugled, debug);
  }
  else if (debuginit)
    digitalWrite (debugled, debuginit);
  else
    digitalWrite (debugled, false);
}

/*void head_light_updater()
{
  if (photo < 500)
  {
    if (no_BLUETOOTH_com && (millis() - previousDEBUGupdate) > 500) 
      digitalWrite (head_lights, !digitalRead(head_lights));
    else
      digitalWrite(head_lights, true);
  }
  else
    digitalWrite(head_lights, false);
}

void tail_light_updater()
{
  if (drive.read() > 90 || photo < 500)
  {
    if (no_BLUETOOTH_com && (millis() - previousDEBUGupdate) > 500)
      digitalWrite (tail_lights, !digitalRead(tail_lights));
    else
      digitalWrite (tail_lights, true);
  }
  else
    digitalWrite (tail_lights, false);
}

void button_updater()
{
  if (digitalRead(button) && ((millis() - previousBUTTONupdate) > 1000))
  {
    button_state = !button_state;
    previousBUTTONupdate = millis();
  }
}

void buzzer_updater(bool buzz)
{
  if (drive.read() > 90 && (millis() - previousBUZZupdate > 500))
  {
    previousBUZZupdate = millis();
    
    digitalWrite(buzzer, !digitalRead(buzzer));
    
  }
  else
    digitalWrite(buzzer, buzz);
}*/
void GET_PHONE_DATA()
{
  if(bluetooth.available() > 0)
  {
    previousBLUETOOTHupdate = millis();
    //previousACCELupdate = millis();
    no_BLUETOOTH_com = false;
    char aChar = bluetooth.read();
    if(aChar >= 'A' && aChar <= 'Z' && !started)
    {
      started = true;
      
      Phone_Flag = aChar;
      
      index = 0;
      PhoneinData[index] = '\0';
    }
    else if(aChar == 19 && !ended)
    {
      ended = true;
    }
    else if(started)
    {
      PhoneinData[index] = aChar;
      index++;
      PhoneinData[index] = '\0';
    }
  }
  else
    no_BLUETOOTH_com = true;
  if(started && ended)
  {
   if (Phone_Flag == 'A')
   {    
     previous_phone_gyro[0] = phone_gyro[0];
     previous_phone_gyro[1] = phone_gyro[1];
     previous_phone_gyro[2] = phone_gyro[2];
     
     phone_gyro[0] = atoi(strtok(PhoneinData, ";"));
     phone_gyro[1] = atoi(strtok(NULL, ";"));
     phone_gyro[2] = atoi(strtok(NULL, ";"));
     
     if (previous_phone_gyro == phone_gyro)
       previousGYROupdate = millis();
     
     if (previous_phone_gyro == phone_gyro && (previousBLUETOOTHupdate - previousGYROupdate) > 500)
     {
       no_BLUETOOTH_com = true;
     }
   }
   else if (Phone_Flag == 'B')
   {
    phone_accel[0] = atoi(strtok(PhoneinData, ";"));
    phone_accel[1] = atoi(strtok(NULL, ";"));
    phone_accel[2] = atoi(strtok(NULL, ";"));
   }
   else if (Phone_Flag == 'C')
   {
     phone_call_state = atoi(PhoneinData);
   }
   else if (Phone_Flag == 'D')
   {
     phone_light = atoi(PhoneinData);
   }
   else if (Phone_Flag == 'E')
   {
     phone_compass = atoi(PhoneinData);
   }
   else {}

   // Get ready for the next time
   started = false;
   ended = false;
    
   index = 0;
   PhoneinData[index] = '\0';
  }
  if (no_BLUETOOTH_com && (millis() - previousBLUETOOTHupdate) > 5000)
    no_BLUETOOTH_com = true;
  else
    no_BLUETOOTH_com = false;
  /*
  if((previous_phone_gyro[0] == phone_gyro[0] && previous_phone_gyro[1] == phone_gyro[1] && previous_phone_gyro[2] == phone_gyro[2]) && (previous_phone_accel[0] != phone_accel[0] && previous_phone_accel[1] != phone_accel[1] && previous_phone_accel[2] != phone_accel[2]))
    phones_screen_off = true;
  else
    phones_screen_off = false;
  */
}
#define seg_display[]        [28,29,30,31,32,33,34,35] //A,B,C,D,E,F,G,RHDP

Here's another that's going to bite you in the posterior.

It’s probably this:

{
drive.run(FORWARD);
drive.setSpeed(power);
)
else if (power < 0 && power >= -255)

Funny, Ian - I was expecting to see a comment from you about it being better than an unqualified ego. :slight_smile:

(well spotted)

Wow. If it were me, I'd change a lot of those #defines to const unsigned char...

The compiler will type check for you with variables, not so much with defines.

Also, the #define of an array, as has been previously mentioned, is downright scary.