So make each of your sub-programs a function and a write a main program that calls the functions based on some conditions. The Arduino can have only one program installed (loaded).
In Arduino Platform, we have learnt to develop a program/sketch based on the following strategies:
1. Identify that there are four separate spaces in an Arduino Sketch/Program.
(1) Global Space : It hold variables that can be accessed by all functions and sub-functions (subroutines) of the program.
(2) Setup Space: It holds variables that will only be used here. It also includes codes (functions/methods) that will be executed only once or for a definite number of times.
(3) Loop Space: It holds variables that will only be used here. It also includes codes that will be executed repeatedly (again and again).
(4) User Space: This space holds sub-programs or subroutines written by the users. These subroutines are called upon from setup() and loop() functions as and when needed.
GolamMostafa: 1. Identify that there are four separate spaces in an Arduino Sketch/Program.
There are no "spaces" in Arduino sketches, they are just normal C++ code,
with two special functions being called from main.
And please don't use that "we have learned" stuff, that sound like the hospital "how do we feel today?"
and at least I did not learn about your strange "spaces".
Whandall:
There are no "spaces" in Arduino sketches, they are just normal C++ code,
with two special functions being called from main.
And please don't use that "we have learned" stuff, that sound like the hospital "how do we feel today?"
and at least I did not learn about your strange "spaces".
There are spaces everywhere - Memory Space, Register Space, Corner Space, Arduino Space, and the like; if we were looking for technical/literal meanings for everything everywhere, there is no end of it; we need to be pragmatic to accept things conceptually.
I remember very clearly that my tutor, at the very first Arduino class, draw 4 rectangular blocks and labelled them as spaces of which two are (usually) unseen to the users -- the Global Space and the User Space. There were literate Arduinians in the class; but, they did not react the way you have reacted.
I don't think there's anything wrong with thinking of the spaces as, well, spaces but I would shy clear of labeling them as Space with a capital-S which makes it seem like some official C/Arduino naming convention.
elvon_blunden:
I don't think there's anything wrong with thinking of the spaces as, well, spaces but I would shy clear of labeling them as Space with a capital-S which makes it seem like some official C/Arduino naming convention.
There is a style/convention for the creation of a Title: Use Capital letters for all the meaningful words of the title; hence the names: Global Space and not Global space; Setup Space and not Setup space...!
GolamMostafa:
There is a style/convention for the creation of a Title: Use Capital letters for all the meaningful words of the title; hence the names: Global Space and not Global space; Setup Space and not Setup space...!
That sort of pedantry is not helpful for the OP. Please start your own Thread if you wish to discuss it.
Neither (IMHO) is introducing a new range of buzz-words, whether they start with an upper-case or a lower-case letter.
Whatever about drawing attention to global and local scope and to the standard functions setup() and main() there is definitely no other "space" that might justify the name "user space". There are just more functions.
...R
PS ... if one must be pedantic then both setup() and loop() use lower-case first letters - and the C/++ programming language is case sensitive.
GolamMostafa:
I remember very clearly that my tutor, at the very first Arduino class, draw 4 rectangular blocks and labelled them as spaces
of which two are (usually) unseen to the users -- the Global Space and the User Space.
There were literate Arduinians in the class; but, they did not react the way you have reacted.
So what?
Does that justify misusing terminology pimped up in a fancy legit looking enumeration?
User space has a common meaning that shares nothing with your new meaning.
Does that justify misusing terminology pimped up in a fancy legit looking enumeration?
User space has a common meaning that shares nothing with your new meaning.
Never Mind! The Arduino/C/C++ language will never accept my new terminologies; it is not going to cause any loss/harm to anybody except those who are reluctant to hear new vocabulary.
GolamMostafa:
I remember very clearly that my tutor, at the very first Arduino class, draw 4 rectangular blocks and labelled them as spaces of which two are (usually) unseen to the users -- the Global Space and the User Space.
Perhaps the guy just edited his COBOL:101 notes.
(I don't like the use of capitals to label these "spaces" either)