LiquidCrystal lcd2(12,10,5,4,3,2);
^~
test.h:6:20: error: expected ',' or '...' before numeric constant
test.h:12:3: error: invalid use of member function 'LiquidCrystal Display2::lcd2(int)' (did you forget the '()' ?)
lcd2.begin(16,2);
^~~~
Show the full error trace
What’s the other file you have for testing ? Do you have a test,cpp ?
Does it make any sense instantiating the lcd in every instance of your class ? And if there is only one instance ever created, why would the lcd be hard coded in there ?
Otherwise syntaxically just declare it’s a LiquidCrystal (pointer) typed variable and call it’s constructor in your class constructor that’s where it will really be instantiated and parameters needed
Ok here's the full error trace, and that other file is just has the #include "test.h", as well as setup(), and loop() functions are, but they don't contain anything. Also, I don't have a .cpp file.
In file included from C:\Users\airpl\Documents\Arduino\Helmet_v1\Helmet_v1.ino:2:0:
test.h:6:27: error: expected identifier before numeric constant
extern LiquidCrystal lcd2(12,10,5,4,3,2);
^~
test.h:6:27: error: expected ',' or '...' before numeric constant
test.h:6:40: error: storage class specified for 'lcd2'
extern LiquidCrystal lcd2(12,10,5,4,3,2);
^
sketch\test.h: In member function 'void Display2::use()':
test.h:12:3: error: invalid use of member function 'LiquidCrystal Display2::lcd2(int)' (did you forget the '()' ?)
lcd2.begin(16,2);
^~~~
test.h:12:3: error: invalid use of member function 'LiquidCrystal Display2::lcd2(int)' (did you forget the '()' ?)
exit status 1
expected identifier before numeric constant
And yeah your right, so what else would you recommend I put it so it doesn't create a new instance every time, and out of curiosity how could I, in code, declare it's a LiquidCrystal typed variable and call it's constructor in the class constructor.
I would have a member variable as a pointer to a LiquidCrystal object and you would instantiate the lcd in the main .ino and pass the pointer to the LCD to the constructor of your class.