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