Arduino project splint in two files

Hello,

I need to create a Arduino Project splitted in two files.

In the second file .ino i had declared some variables but when i tryed to set a value for the variables declared in the second file the compiler returned this error:

MGC3130_Demo.ino: In function 'void setup()':
MGC3130_Demo.ino:51:3: error: 'Digital_Input' was not declared in this scope

Anyone can help me please?

Thanks

Move the variables to the main sketch above the setup() function.

What are the names of the files and where are they located ?

Tanks for your reply,

My idea is to divide the project in more files as when developes in C language by Microchip platform.
Therefore i need to create a main file "MGC3130_Demo.ino", a second file with variables "Variables.ino", "MCP23017_DEvice.ino" and so on.

The variables declared into "Variables.ino" file must be visible in each other file .ino

It is possible do it ?

Thanks

When the IDE compiles several .ino files it first reads the main project file and then reads the other files in alphabetical order.

Global variables in an early file are visible in later files, but not vice versa. The simple solution is to put all the global variables in the main project file as that will make them visible to all the other (later) files.

…R

No.

The extern keyword tells the compiler that the variable is defined elsewhere. You can put the files in any order and put the correct definition into the logically correct header file. The linker will find the variables and sort it out for you.

Please read the Arduino Build Process. This explains what sorts of file should be in your sketch directory. There should only be one .ino file.

MorganS:
There should only be one .ino file.

Sorry to disagree. It works perfectly well with multiple .ino files.

...R