Pages: [1]   Go Down
Author Topic: How can I upload multiple sketches  (Read 878 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17294
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How could i combine them?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How could i combine them?
Code:
loop
{
 runSketch_1();
 runSketch_2();
}
loop has to be only one
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How could i combine them?
If you had two recipes to make cookies, how would you combine them?
Logged

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

Croatia
Offline Offline
God Member
*****
Karma: 13
Posts: 508
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Loops are like Highlanders. There can be only one.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I know nothing.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

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

Pages: [1]   Go Up
Jump to: