Pages: [1]   Go Down
Author Topic: Tabs & Function()  (Read 694 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have broken up my code into four Tabs. Each section of code works interdependently, but I can't seem to reference sections of codes with in other Tabs (i.e GOSUB routines in simple speak).

 void Setup and void Loop can only be used once, so I have used alternatives like void LCDsetup1() and void LCDloop2() in other Tabs. Is this the correct way to call up a particular function with in the main function?  
Any sample code that uses Tabs that I could review? :-[
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


You will need to declare the shared functions.  Typically, this is done with header files but they are not required.

Let's say you have a function in one of your tabs...

void LCDsetup( void )
{
  // Prepare the LCD display
}


That you want to call from setup in your Sketch.  Your Sketch might look something like this...

Code:
void LCDsetup( void );

void setup( void )
{
  // Call LCDsetup in the other tab
  LCDsetup();
}

void loop( void )
{
}

Does that help?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply.

Do I need to include th relevant "include" statements a "int" declarations in the appropriate TAB, or can they be included in one main TAB?

i.e. if I have two TABS - (TAB A and TAB B), can I declare all of the int declarations in TAB A, even though though TAB B has the appropriate code  :-[instructions?

That may not make sense....but
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Best thing to do is experiment...
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for......
Logged

Pages: [1]   Go Up
Jump to: