So finally I have managed to get myself into programming with Arduino. I've been trying (on and off) for the past year now to read and learn C but it just wasn't going in. Now with a few little succesful projects under my belt I'm enjoying it and learning faster than ever!
I'm now going onto to write more and more complex programs and just discovered the tab feature in Arduino IDE and my basic question is Can I use these for different function in which I can call from the main program on the first tab? As in are these tabs all part of the same program or are they different projects?
The tabs represent separate files within the same project. To use them effectively, you need to have some understanding of how multiple .cpp and .h files are used in a conventional C++ project - because that's essentially what an Arduino sketch is.
If you want to reuse your code across multiple project then the Arduino approach is to define a library (typically consisting of a collection of .cpp and .h files) which are stored in a libraries directory along side your sketches. The Arduino IDE imposes a restriction that the name of the directory must be the same as the name of a header file within that directory (apart from the .h extension) and you must include that header file in your sketch file to signal to the IDE that you are using that library.
You can add as many tabs and files to the IDE as you like, within reason.
Each new tab will create a new file in the same folder as the main file. Give the new files names with an extension of .ino You can put just about anything that you like in the extra files but they are most useful if used to hold functions called from the main program. This allows you to group functions together logically which makes them easier to find rather than having them bundled in with the main program, but you will need to try it out to see whether you get on with this method of working or not.
You can copy the files to other folders to use them in other programs but you will need to change them all individually if you want/need to make a change to how they work. In contrast to this, library files (.cpp and .h) are held in a central location and can be #included in any program. Because they only exist in one place then changing them makes the changes available to any programs in which they have been #included.
Thanks this sounds good. I like the idea of having the functions separate.
Before I got into programming I used to think why don't we make it easier by using a flow chart theme with different blocks that can be the main, functions etc. so this modular approach is what I would think would be logically coming from a novice looking in.