Pages: [1]   Go Down
Author Topic: Is it possible to combine two sletches  (Read 513 times)
0 Members and 1 Guest are viewing this topic.
Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

and where can I find the necessary documentation to learn how to do so. I have or will have 6 sketches originally to test some modules (sketches) and ultimately be a final sketch for a Mega 2560 I am building a bedside monitor/controller for lights, radio... etc
I tried and got a funny compiler error... on a comment. If I select either of two sketches (files) loaded into the 1.0 IDE and try to verify it either one brings me back to the first one loaded and flags the Comment in yellow as the 'error'...
My original thought was to prove the hardware and then 'put it all together' as the whole thing has an X10 module a GLCD module a baro/temperature module a hygrometer module and a time module using a GPS receiver as a 'time server' hopefully I will also be able to add a sure 3208 display module with 2 3208 boards. THe Baro, glcd (adafruit 7735 for now) and hygrometer modules work, so far

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6134
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It isn't a matter of copying and pasting chunks together, unless each chunk was designed to work entirely standalone and can run in a serial manner.  Otherwise, you need take the existing code as a template for creating a new project that combines all of the new elements.

As you can see, there isn't a straightforward answer, these are just the results from the first search page of "combining sketches":
http://arduino.cc/forum/index.php/topic,103386.0.html
http://arduino.cc/forum/index.php/topic,59415.0.html
http://arduino.cc/forum/index.php/topic,54872.0.html
http://arduino.cc/forum/index.php/topic,79365.0.html
http://arduino.cc/forum/index.php/topic,52748.0.html
http://arduino.cc/forum/index.php/topic,70807.0.html
Logged

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

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

James, The answer is that yes beyond devices using the same bus I2C or SPI and on a Mega there are plenty of ports and everything except time once a second and radio communication to the room display board can and really is a separate asynchronous task. The X10 stuff can wait for an opening time slot as a second or two's delay isn't a real issue for controlling lights or turning on appliances.
Does this help?...

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Re: Combining Sketches.
It occurs to me that If I turn the sketches onto functions and call them as I need them to return the data. I have a tricky thing to do... learning how to make the functions work.
The rest is in making the correct pin assignments. The really hard part I think will be handling the serial displays; GLCD, Character (4 X 20) and serial 3208 display modules... maybe an Uno with the mega??? for communications only? Do-Able I think. Might not even need more than a Mega
Do I have any opinions?

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 602
Posts: 33375
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I made an attempt at describing it here:-
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I read it the first time and saved the URL as I thought it Very Useful, Thank You for a great link.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Pages: [1]   Go Up
Jump to: