question using tabs

if I put this in main before loop it works if I call it from loop. when I move it to a new tab none of the global variables are available . How do I make the tab part of the main so I can do this ?
I have tried #include "tabname.ino" but it don't work.

void LcdUpdate ()

            if (((currentMillis - currentMillis3)  > (1000)) && (digitalRead(A7) == 1))
                                                                lcd.setCursor(0, 0);
                                                                lcd.print("Interval mS");
                                                                lcd.setCursor(12, 0);
                                                                lcd.print(Interval * 2);
                                                                lcd.setCursor(0, 1);
                                                                lcd.print("Duration mS");
                                                                lcd.setCursor(12, 1);
                                                                lcd.setCursor(0, 2);
                                                                lcd.setCursor(12, 2);
                                                                lcd.setCursor(0, 3);
                                                                lcd.print("POT A4");
                                                                lcd.setCursor(12, 3);
                                                                currentMillis3 = currentMillis;

Almost impossible to say without seeing all of the code. As you have suggested, it is likely due to the variables you think are global not being defined. As one tends to #include a library before any other code, the variables you're trying to use have not yet been defined. In a case as simple as this, make the equivalent variables local and pass the values;

LcdUpdate(currrentMillis, currentMillis3);


void LcdUpdate(uint32_t cM, uint32_t cM3)
{ ...

and change the references in your function from currentMillis and currentMillis3 to cM and cM3.

Something would have to be done with button and pot, but no way to tell from a fragment.

When you put code in tabs (multiple .ino files) the Arduino IDE first loads the principal file (with the same name as the folder) and then loads the other files in alphabetical order.

Global variables in an early file are visible to code in a later file but not vice versa. Maybe use the principal file for the variables and the other files for code.


Check this working Code with several .ino and .h

the globals are ALL in the 1st Tab where setup() and loop() is.