I'm building a midi controller that controls elements in DJ software. I have two tabs in my sketch, one is to allow the Mega to send/receive midi information and the other is to register a button to send midi note off and on functions. However when i'm verifying i keep getting the redefinition of Void setup or Void Loop, Being a big noob to coding, i have no idea how to re arrange the void setup or loop function with two tabs
Do you have a setup() or loop() function in both of the tabs?
Yeah i have both of them in each tab, i'm just unsure how to rearrange the code so i only have one of each
Normally you'd just copy the contents of one setup() into the other setup(), then delete the empty one.
When you have multiple tabs in a sketch (assuming they are .ino files), they are combined into a single file in the order the tabs are shown in the Arduino IDE when you compile.
There is no magic to multiple tabs. It just helps to make large sketches easier to navigate, rather than having to scroll forever to find some code.
To add to the already helpful advice here, as a new programmer, there are two ways you might find useful to look at tabs.
One is just realize they are like page breaks in a book - don't make any difference to the code stream when it is compiled, just splits things into manageable chunks. You will always have only one setup function and one loop function in one program.
The other is to think of them as a main program area and multiple function references. You may not be completely familiar with functions yet; they are a way of splitting out repeatable bits of code and making them easily callable from anywhere. Tabs are great for that and some programmers use them extensively that way. You write a function once, and add that tab to any program that needs to use it. If using that way, there would be one setup function and one void function (usually in the first tab), and additional functions in additional tabs.