Unqualified ID using arduino nano every

I have a problem, i Wrote this code

#include <Servo.h>
#include "Wire.h"
#include <MPU6050_light.h>

#define ESC_PIN 12    //where the motor is connected
#define Aileron_Servo_Left 11   //where the Left Aileron is connected 
#define Aileron_Servo_Right 10 //where the Right Aileron is connected 
#define Elevator 9  //where the left Elevator is connected
#define Rudder 8  //where the Rudder is connected 

#define ch1 2 //Throttle input
#define ch2 3 //Aileron input
#define ch3 4 //Elevator Input
#define ch4 5 //Rudder Input
#define ch5 6 //Gear Flipp(Autopilot on/off)

volatile long Throttle_StartTime = 0;
volatile long Throttle_CurrentTime = 0;
volatile long Throttle_Pulses = 0;

volatile long Aileron_StartTime = 0;
volatile long Aileron_CurrentTime = 0;
volatile long Aileron_Pulses = 0;

volatile long Elevator_StartTime = 0;
volatile long Elevator_CurrentTime = 0;
volatile long Elevator_Pulses = 0;

volatile long Rudder_StartTime = 0;
volatile long Rudder_CurrentTime = 0;
volatile long Rudder_Pulses = 0;

volatile long Gear_StartTime = 0;
volatile long Gear_CurrentTime = 0;
volatile long Gear_Pulses = 0;

unsigned long timer = 0;

MPU6050 mpu(Wire);
Servo esc;
Servo Aileron_Left;
Servo Aileron_Right;
Servo Elevator;
Servo Rudder;


int Throttle_PulseWidth = 0;
int Aileron_PulseWidth = 0;
int Elevator_PulseWidth = 0;
int Rudder_PulseWidth = 0;
int Gear_PulseWidth = 0;

int motorspeed;
int Aileron_R_Angle;
int Aileron_L_Angle;
int Elevator_Angle;
int Rudder_Angle;
int Gear_Position;

void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  byte status = mpu.begin();
  Serial.print(F("MPU6050 status: "));
  Serial.println(status);
  while(status != 0) {} //stop everything if gyro cannot be found

  Serial.println(F("Calculating offsets, do not move MPU6050"));
  delay(2000);  //continue to arm 
  mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down
  mpu.calcOffsets();
  Serial.println("Done :) :) :)\n");

  pinMode (ch1, INPUT_PULLUP); //Throttle input
  pinMode (ch2, INPUT_PULLUP); //Aileron input
  pinMode (ch3, INPUT_PULLUP); //Elevator Input
  pinMode (ch4, INPUT_PULLUP); //Rudder Input
  pinMode (ch5, INPUT_PULLUP); //Gear Input  

  //attachInterrupt (digitalPinToInterrupt(ch1), Throttle_PulseTimer, CHANGE);
  //attachInterrupt (digitalPinToInterrupt(ch2), Aileron_PulseTimer, CHANGE);
  //attachInterrupt (digitalPinToInterrupt(ch3), Elevator_PulseTimer, CHANGE); 
  //attachInterrupt (digitalPinToInterrupt(ch4), Rudder_PulseTimer, CHANGE);
  attachInterrupt (digitalPinToInterrupt(ch5), Gear_PulseTimer, CHANGE);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Gear_Pulses < 2000) {
    Gear_PulseWidth = Gear_Pulses;
  }

  if  (Throttle_Pulses < 1916) {
    Throttle_PulseWidth = Throttle_Pulses;
  }

  if(Aileron_Pulses < 2000) {
    Aileron_PulseWidth = Aileron_Pulses;
  }

  if(Elevator_Pulses < 2000) {
    Elevator_PulseWidth = Elevator_Pulses;
  }

  if(Rudder_Pulses < 2000) {
    Rudder_PulseWidth = Rudder_Pulses;
  }
  Gear_Position = map (Gear_PulseWidth, 1000, 2000, 0, 1);

  Serial.print(Gear_Position);
}

void Gear_PulseTimer() {
  Gear_CurrentTime = micros();
  if(Gear_CurrentTime > Gear_StartTime) {
    Gear_Pulses = Gear_CurrentTime - Gear_StartTime;
    Gear_StartTime = Gear_CurrentTime;
  }
}


and now for some reason the compiler is giving me the Error message Unqualified ID, at pin 8 and 9 of my arduino nano every. HELP

Please post the full error message using code tags.

D:\Arduino\Arduino Projects\Final Autopilot\Final Autopilot.ino:8:18: error: expected unqualified-id before numeric constant
 #define Elevator 9  //where the left Elevator is connected
                  ^
D:\Arduino\Arduino Projects\Final Autopilot\Final Autopilot.ino:43:7: note: in expansion of macro 'Elevator'
 Servo Elevator;
       ^~~~~~~~
D:\Arduino\Arduino Projects\Final Autopilot\Final Autopilot.ino:9:16: error: expected unqualified-id before numeric constant
 #define Rudder 8  //where the Rudder is connected
                ^
D:\Arduino\Arduino Projects\Final Autopilot\Final Autopilot.ino:44:7: note: in expansion of macro 'Rudder'
 Servo Rudder;
       ^~~~~~

exit status 1

Compilation error: expected unqualified-id before numeric constant

this is the full error message that i get

which cpu? Is "8" and "9" a legal pin for this use?

You have a #define Rudder. Next you create a new servo object that has the same name.

Look at servo examples how you pass the pin to the constructor.

:man_facepalming:

i feel so embarassed after changing them to Rudder_servo it works.

thanks so much

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