NOT DECLARED IN SCOPE

I'm horrible at programming (just know VERY basic) and am using someones else's codes from github. Keep getting this message whenever I try to upload to the arduino nano: PA1 not declard in scope. How do I fix this line of code? Thanks!
void setup()
{

ServoX.attach(PA1); // attaches the X servo on PA1 for stm32 or D10 for the Arduino Uno
ServoY.attach(PA2); // attaches the Y servo on PA2 for stm32 or D11 for the Arduino Uno

// set both servo's to 90 degree
ServoX.write(90);
ServoY.write(90);
delay(500);

Wire.begin();

Serial1.begin(38400);
while (!Serial1); // wait for Leonardo enumeration, others continue immediately

// initialize device
Serial1.println(F("Initializing MPU 6050 device..."));
mpu.initialize();

// verify connection
Serial1.println(F("Testing device connections..."));
Serial1.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

// load and configure the DMP
Serial1.println(F("Initializing DMP"));
devStatus = mpu.dmpInitialize();

// INPUT CALIBRATED OFFSETS HERE; SPECIFIC FOR EACH UNIT AND EACH MOUNTING CONFIGURATION!!!!
// use the calibrate function for yours
// you can also write down your offset ans use them so that you do not have to re-run the calibration

ax_offset = 1118;
ay_offset = 513;
az_offset = 1289;
gx_offset = 64;
gy_offset = -1;
gz_offset = -33;
// configure LED for output
pinMode(LED_PIN, OUTPUT);
calibrate();
initialize();
}

The problem is in the code you didn't post.

Sorry about that. here it is

RocketMotorPIDGimbal.ino (15.1 KB)

I can see enough in your picture to determine the code is called RocketMotorPIDGimbal.ino, so had to search for it on google.

That code is written for an STM32F103C, you will have to make a few changes to get it to work on an UNO/NANO. The pin definition differences are detailed in the comments at the beginning of the code. Unfortunately the author didn't set it up to easily adjust the code between the different boards.

Thank you! That's what i suspected. I guess I'l go through the codes and change all the pins to the one on arduino nanos?

whever i try to upload this code to the arduino nano board, it keeps doing this. I am useing this board. I am still a beginner at programming and did not code this (got it off of github).
sketch is here:

from line 108, it keeps saying PA1 was not declared in scope. that part shown below. (I probably look stupid,lol. Your typical nooby. Thanks for your help though!)

ServoX.attach(PA1); // attaches the X servo on PA1 for stm32 or D10 for the Arduino Uno
ServoY.attach(PA2); // attaches the Y servo on PA2 for stm32 or D11 for the Arduino Uno

// set both servo's to 90 degree
ServoX.write(90);
ServoY.write(90);
delay(500);

Wire.begin();

Serial1.begin(38400);
while (!Serial1); // wait for Leonardo enumeration, others continue immediately

// initialize device
Serial1.println(F("Initializing MPU 6050 device..."));

Post the whole sketch and the complete error messages please.

Scope means "where the variable name is valid in the program". The compiler's saying you haven't
declared PA1

Thank you! This is the error code is below. The sketch is linked above
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:nano:cpu=atmega328old -build-cache /tmp -build-path /tmp/419444375/build -verbose -prefs runtime.tools.avr-gcc.path=./opt/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 -prefs runtime.tools.avrdude.path=./opt/tools/avrdude/6.3.0-arduino14 -prefs runtime.tools.arduinoOTA.path=./opt/tools/arduinoOTA/1.2.1 -libraries /tmp/419444375/custom -libraries /tmp/419444375/pinned /tmp/419444375/RocketMotorPIDGimbal

Multiple libraries were found for "Servo.h"

Used: /home/ubuntu/opt/libraries/latest/servo_1_1_3

Not used: /home/ubuntu/opt/libraries/latest/rokitsmart_1_0_9

Not used: /home/ubuntu/opt/libraries/latest/printoo_library_1_0_2

Not used: /home/ubuntu/opt/libraries/latest/evive_2_0_1

Multiple libraries were found for "I2Cdev.h"

Used: /home/ubuntu/opt/libraries/latest/mpu6050_0_0_1

Not used: /home/ubuntu/opt/libraries/latest/grove_imu_9dof_1_0_0

Not used: /home/ubuntu/opt/libraries/latest/grove_imu_9dof_1_0_0

Not used: /home/ubuntu/opt/libraries/latest/grove_imu_9dof_1_0_0

Not used: /home/ubuntu/opt/libraries/latest/grove_imu_9dof_1_0_0

Using library Wire at version 1.0 in folder: /home/ubuntu/opt/cores/arduino/avr/libraries/Wire

Using library pid_1_2_0 at version 1.2.0 in folder: /home/ubuntu/opt/libraries/latest/pid_1_2_0

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void setup()':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:108:17: error: 'PA1' was not declared in this scope

ServoX.attach(PA1); // attaches the X servo on PA1 for stm32 or D10 for the Arduino Uno

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:109:17: error: 'PA2' was not declared in this scope

ServoY.attach(PA2); // attaches the Y servo on PA2 for stm32 or D11 for the Arduino Uno

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:119:3: error: 'Serial1' was not declared in this scope

Serial1.begin(38400);

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:38:17: error: 'PC13' was not declared in this scope

#define LED_PIN PC13 //pin 13 for the arduino Uno and PC13 for the stm32

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:146:11: note: in expansion of macro 'LED_PIN'

pinMode(LED_PIN, OUTPUT);

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void initialize()':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:153:3: error: 'Serial1' was not declared in this scope

Serial1.println(F("Initializing MPU 6050 device..."));

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void myloop()':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:218:5: error: 'Serial1' was not declared in this scope

Serial1.println(F("FIFO overflow!"));

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:38:17: error: 'PC13' was not declared in this scope

#define LED_PIN PC13 //pin 13 for the arduino Uno and PC13 for the stm32

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:248:16: note: in expansion of macro 'LED_PIN'

digitalWrite(LED_PIN, blinkState);

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:272:3: error: 'Serial1' was not declared in this scope

Serial1.print(mpuPitch);

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void serialPrintFloatArr(float*, int)':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:292:5: error: 'Serial1' was not declared in this scope

Serial1.print(",");

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void serialFloatPrint(float)':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:307:5: error: 'Serial1' was not declared in this scope

Serial1.print(c1);

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void calibrate()':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:321:3: error: 'Serial1' was not declared in this scope

Serial1.println("\nMPU6050 Calibration Sketch");

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void calibration()':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:435:5: error: 'Serial1' was not declared in this scope

Serial1.println("...");

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:38:17: error: 'PC13' was not declared in this scope

#define LED_PIN PC13 //pin 13 for the arduino Uno and PC13 for the stm32

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:437:18: note: in expansion of macro 'LED_PIN'

digitalWrite(LED_PIN, blinkState);

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void MainMenu()':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:472:10: error: 'Serial1' was not declared in this scope

while (Serial1.available())

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino: In function 'void interpretCommandBuffer(char*)':

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:499:5: error: 'Serial1' was not declared in this scope

Serial1.println(F("calibration\n"));

^

/tmp/419444375/RocketMotorPIDGimbal/RocketMotorPIDGimbal.ino:514:5: error: 'Serial1' was not declared in this scope

Serial1.println(F("Unknown command" ));

^

exit status 1

You will need to replace:

PA1 with 10
PA2 with 11
PC13 with 13

Also replace all references to Serial1 with Serial.

Appears to compile after that, as to whether it will function properly I don't know.

The pre-defined pin definitions are different for the boards, so PA1, PA2, and PC13 are undefined for an uno/nano, and the serial port numbering is a bit different.

Thanks! Will try. Seems to be helping

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

@CFUYukon, please do not cross-post. Threads merged.

Sorry, everyone. Got so frustrated so I just went on and posted before I even learned how this forum works. I read the rules and stuff and the software is debugged. Thank you everyone for your help! I really appreciate it :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

Hi,
Can you post your working code so as to complete the problem solving process of this thread?

Thanks.. Tom... :slight_smile:

Oh sorry, forgot. I tried to post the code on using but was too long. Here is the link to the sketch. I renamed it so it can't be confused with the original. Also .ino file below. Thank you everyone for your help

Rocketmotor_PID_update.ino (15 KB)

CFUYukon:
Oh sorry, forgot. I tried to post the code on using but was too long. Here is the link to the sketch. I renamed it so it can't be confused with the original. Thank you everyone for your help
Arduino Cloud

Rocketmotor_PID_update.ino (15 KB)