What I'm trying to figure out is how to use a variable to point to different character devices. Here's an example of what I want to do:
static LiquidCrystal LCD (_RS, _RW, _EN, _D4, _D5, _D6, _D7); // setup the LCD Serial.begin (115200); // setup the serial port static PTR; // will be set to various char devices PTR = Serial; PTR.println ("Hello there serial port"); // goes to the serial port PTR = LCD; PTR.println ("Hello there LCD display"); // goes to the LCD
I've tried everything I can think of and nothing works (i.e. I get various compiler errors).
Trying "static Print &ptr = 0" compiles, but gives me an error that certain functions do not exist (such as Serial doesn't have "createChar" like LCD does).
The only thing that DOES work is to use #define... but I would rather not do it that way.
Any ideas will be appreciated!