How can I upload multiple sketches

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

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

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

How could i combine them?

Kenn13542:
How could i combine them?

loop
{
 runSketch_1();
 runSketch_2(); 
}

loop has to be only one

Kenn13542:
How could i combine them?

If you had two recipes to make cookies, how would you combine them?

Loops are like Highlanders. There can be only one.

[quote author=James C4S link=topic=149249.msg1121846#msg1121846 date=1361039710]

Kenn13542:
How could i combine them?

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

A4kash:
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.