Go Down

Topic: how do you brake a single sketch down to multiple sketches ? (Read 496 times) previous topic - next topic

Alex_the_Lion

Feb 14, 2013, 01:50 pm Last Edit: Feb 14, 2013, 01:59 pm by Alex_the_Lion Reason: 1
I have been using Ardunio for about a year now and I need help.
I have looked for resources to figure out how to refer to another sketch from the sketch you are programming. My code has gotten big enough to break a sketch down into smaller sketches.
Does Ardunio use dot notation or some other method to refer to the other sketch?
EG
Code: [Select]

"sketch1"

void setup(){
sketch2.method1();
}


Code: [Select]

"sketch2"

void setup(){
Serial.begin(9600);
}

void loop(){}
void method1(){

Serial.println("Hello World");
}


is this right or wrong?
I am being buried under the never ending sketch.

PaulS

Create a new tab, naming the file associated with that tab with a .ino extension. All .ino files are merged at compile time.

Nothing needs to be done to call a function defined in another .ino file, since the compiler will only see one .cpp file when it gets called.

tuxduino

But remember there can be only one one setup() and one loop() function.

Alex_the_Lion

what you are saying PaulS is you can refer to another method in an .ino file by the method name only. If I understand you correctly.

PaulS

Quote
what you are saying PaulS is you can refer to another method in an .ino file by the method name only. If I understand you correctly.

Yes. You do.


MarkT

If parts of the sketch might be useful in other projects, then consider encapsulating that part in a library.
[ I won't respond to messages, use the forum please ]

Go Up