OP probably wants access to the LCD thus attempted to do the instantiation inside a class def. If OP would tell more details of the project, maybe we can find a solution.
PaulS:
I don't know the source of your problem, but using pin 1 for the LCD is not really a good idea.
I don't think that is a real problem in it's self. Pin 1 is the arduino's Tx pin and thus is a output pin that in his case would be wired to two places, the on-board USB input pin and the external LCD input pin, no problem electrically about that.
It's using pin 0 where a problem exists if you wire an external serial device to it as then you have two output pins, the USB chip and the external device wired together to the arduino Rec pin, and that can only lead to problems in most cases such as failed uploads, etc. The 1k isolation resistor wired in series to the USB pin will prevent electrical damage, but corrupted serial data is sure to happen.
@PaulS, The numbers I'm using for the pins are fake. I just couldn't remember which real pins I was using when I started typing this code.
@Bubulindo, Yes, I'm instantiating a LiquidCrystal inside a class definition. This is valid C++ code, and shouldn't cause an error, especially the strange message that I'm getting.
lincomatic:
Here’s a small fragment of code that causes a weird error:
#include <LiquidCrystal.h>
class obd {
LiquidCrystal lcd(1,2,3,4,5,6);
public:
obd() {}
};
Does anyone know how to fix this?
I think you have to write:
#include <LiquidCrystal.h>
class obd {
LiquidCrystal lcd; // Leave out the constructor arguments
public:
obd() {}
};
// Define the constructor and explicitly call the constructors for member objects:
obd::obd() : lcd(1,2,3,4,5,6)
{
}