Go Down

Topic: How can I upload multiple sketches (Read 938 times) previous topic - next topic

Kenn13542

I have tried uploading multiple sketches, using tabs in the Arduino IDE, but it keeps coming up with:

Fading_Green.ino: In function 'void setup()':
Fading_Green:16: error: redefinition of 'void setup()'
Decoder_Sketch:34: error: 'void setup()' previously defined here
Fading_Green.ino: In function 'void loop()':
Fading_Green:22: error: redefinition of 'void loop()'
Decoder_Sketch:39: error: 'void loop()' previously defined here


They are in two differnt tabs and I thought that, that would solve it, but it didn't,
Any help with uploading multiple sketches would be great.

Thanks,Ken

retrolefty


I have tried uploading multiple sketches, using tabs in the Arduino IDE, but it keeps coming up with:

Fading_Green.ino: In function 'void setup()':
Fading_Green:16: error: redefinition of 'void setup()'
Decoder_Sketch:34: error: 'void setup()' previously defined here
Fading_Green.ino: In function 'void loop()':
Fading_Green:22: error: redefinition of 'void loop()'
Decoder_Sketch:39: error: 'void loop()' previously defined here


They are in two differnt tabs and I thought that, that would solve it, but it didn't,
Any help with uploading multiple sketches would be great.

Thanks,Ken


One can only upload a single sketch to a arduino board, it's a rule one arduino board, one sketch to run. If you have multiple sketches each with their own setup() and loop() function then you can't combine them by using the tabbed edit windows, as again you can only compile and load one sketch.

What you may want to do is to write one single sketch that performs all the same tasks that the individual sketch tasks did. That would require combining the coding somewhat manually and making sure you don't duplicate function or variable names and don't use the same hardware resources like pin numbers for the different tasks.

I bet this doesn't help?

Lefty

Kenn13542


kapelan


How could i combine them?

Code: [Select]
loop
{
runSketch_1();
runSketch_2();
}

loop has to be only one

James C4S


How could i combine them?

If you had two recipes to make cookies, how would you combine them?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Shpaget

Loops are like Highlanders. There can be only one.

A4kash



How could i combine them?

If you had two recipes to make cookies, how would you combine them?
can't we run them simultaneously through a single sketch.

James C4S


can't we run them simultaneously through a single sketch.

If both programs are re-written to run as one, you can switch between them.  But this almost always means conflicts.

The microcontroller used in the Arduino is a very single minded device.  It isn't like a PC with an operating system that can easily store and run multiple programs.

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up