Skip to main content
added 78 characters in body
Source Link
William Roy
  • 515
  • 4
  • 10
  • 22

I have 2 .ino files (2 tabs) for one Arduino project/sketch: MySketch1MySketch_File1.ino and MySketch2MySketch_File2.ino. 

I declared in MySketch2MySketch_File2 variables and functions which I want to use in MySketch1MySketch_File1, but I get this error massage:

error: 'a' was not declared in this scope

//MySketch1MySketch_File1.ino
void setup(){
Serial.begin(9600);
Serial.println(String(a));
}

void loop(){

}

Second file:

//MySketch2MySketch_File2.ino
int a;

How can I declare variables and functions one time in one .ino file and use it across multiple .ino files?

I have 2 files: MySketch1.ino and MySketch2.ino. I declared in MySketch2 variables and functions which I want to use in MySketch1, but I get this error massage:

error: 'a' was not declared in this scope

//MySketch1.ino
void setup(){
Serial.begin(9600);
Serial.println(String(a));
}

void loop(){

}

Second file:

//MySketch2.ino
int a;

How can I declare variables and functions one time in one .ino file and use it across multiple .ino files?

I have 2 .ino files (2 tabs) for one Arduino project/sketch: MySketch_File1.ino and MySketch_File2.ino. 

I declared in MySketch_File2 variables and functions which I want to use in MySketch_File1, but I get this error massage:

error: 'a' was not declared in this scope

//MySketch_File1.ino
void setup(){
Serial.begin(9600);
Serial.println(String(a));
}

void loop(){

}

Second file:

//MySketch_File2.ino
int a;

How can I declare variables and functions one time in one .ino file and use it across multiple .ino files?

Source Link
William Roy
  • 515
  • 4
  • 10
  • 22

How to use variables and functions across multiple .ino files

I have 2 files: MySketch1.ino and MySketch2.ino. I declared in MySketch2 variables and functions which I want to use in MySketch1, but I get this error massage:

error: 'a' was not declared in this scope

//MySketch1.ino
void setup(){
Serial.begin(9600);
Serial.println(String(a));
}

void loop(){

}

Second file:

//MySketch2.ino
int a;

How can I declare variables and functions one time in one .ino file and use it across multiple .ino files?