Is it possible to call members of Serial1 from another class?
Yes, it is.
I tried to do:
Serial1.write()
from a class member function but the compiler said "Serial1 not defined in this scope"
Does the class implementation include HardwareSerial.h? That is where Serial1 is defined.
So, I tried to pass in a reference to it like this:
Void Buzzer::Buzzer(Serial *);
That is not a reference. That is a pointer. Big difference.
But it didn't care for that either.
Well, I'm not surprised. The Void return type, for instance, is undefined. The void return type is.
What's the right way to do this?
There are several. The best one depends on your unstated goals. Why Serial1, instead of Serial or Serial3? Shouldn't the user of the library be able to define the serial instance to use? What if the user of your library wants to use a software serial instance, instead? Will that be accommodated?
Well I guess I typed that post too quickly. Yes, you're right, of course there is a big difference between a pointer and a reference. And I should not have capatilized void. I didn't past that code from my actual code, I just typed it.
I'm not actually writing a library, just a class to encapsulate control of a particular device that is controlled by sending commands to. I know it will always be Serial1.
Let me try including that header file, thank you very much!