Pages: [1]   Go Down
Author Topic: Combining Sketches  (Read 451 times)
0 Members and 1 Guest are viewing this topic.
Hayward, Ca
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am a student and new to Arduino microcontroller.  My project is a Wireless Environment System which includes sensors (photocell, temperature and humidity).  I decided to write the sketches (program) in section and now I have to combine them.

Can someone give me suggest on how to combine my sketches so they can work together.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24298
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/forum/index.php/topic,97455.0.html
You read this, didn't you?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

The Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ctrl+C Ctrl+V
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 435
Posts: 23611
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's one way:

Put all the parts that go before void setup together.
Put all the parts in void setup together.
Write a blink without delay section to run the rest quasi- concurrently:

add these to your declarations:
unsigned long previousMillis();
byte sketchSelect = 0;
Code:
void loop(){
if (millis() >=previousMillis){
previousMillis = previousMillis+100; // each gets 100mS, then next one start
sketchSelect = sketchSelect +1;
if (sketchSelect == 4){ sketchSelect = 1;}
}
switch (sketchSelect){
case 1:
// sketch 1
break;
case 2:
// sketch 2
break;
case 3:
// sketch 3
break;
} // end switch
} // end loop
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Canada
Offline Offline
Sr. Member
****
Karma: 0
Posts: 318
Sometimes teaching, always learning,
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is Grumpy Mike's page:

http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html
Logged


Pages: [1]   Go Up
Jump to: