Hello, I have defined and structure in the main skectch and I can use it, however I would like to have it in an external file to be imported, I am an new on it and I can not get it.
I MOVE the struct to another file named estructura.h, I put it inside libraries folder in his own folder with the same name (estructura) and I import like this in the main sketch: #include <estructura.h>
... however I get errors... with types and similar when I just copy (obviusly deleting in the main skecth).
More info: I am getting errors about boolean..... (As I told you, it works perfect from the main sketch)
content of estructura.h
enum btipo {
men,
luz,
per,
gen,
esc,
};
struct TBoton
{ char nombrebt[13]; de fin
// char etiqueta[13];
boolean estado;
btipo tipoboton;
boolean regulado;
int valorreg;
};
In file included from pruestructura.ino:2:0:
C:\Users\Pascual\Documents\Arduino\libraries\estructura/estructura.h:13:3: error: 'boolean' does not name a type
boolean estado; //estado del boton
^
C:\Users\Pascual\Documents\Arduino\libraries\estructura/estructura.h:15:3: error: 'boolean' does not name a type
boolean regulado; //si es o no boton regulable
^
pruestructura:16: error: too many initializers for 'TBoton'
pruestructura:16: error: cannot convert 'bool' to 'btipo' in initialization
pruestructura:17: error: too many initializers for 'TBoton'........
struct TBoton
{ char nombrebt[13]; de fin // <----- de fin ???
// char etiqueta[13];
boolean estado;
btipo tipoboton;
boolean regulado;
int valorreg;
};
pabusa:
Eiii, thank you very much, it solves the problem. But
Could you explain why is it necessary???
Because "boolean" is not a native c/c++ type. It is defined in Arduino.h. If you don't want to include Arduino.h, then simply use "bool", which is a native c/c++ type instead of "boolean".
RayLivingston:
Because "boolean" is not a native c/c++ type. It is defined in Arduino.h. If you don't want to include Arduino.h, then simply use "bool", which is a native c/c++ type instead of "boolean".
Regards,
Ray L.
Ummm, ok, it is really curious, so to use the native type ... (boolean) I need to import... it is like "think the opposite"
pabusa:
Ummm, ok, it is really curious, so to use the native type ... (boolean) I need to import... it is like "think the opposite"
Thank you!!
No, you said that exactly backwards. boolean is NOT native, bool is native. You have to DEFINE any type before you can declare a variable of that type. bool is defined in the c language, so you can always use it. boolean is defined in Arduino.h, so you can use it ONLY if you include Arduino.h.