Hello
I tried to use a Serial to print off a message (like for example when it's printed after being initialised).
However, it only printed one character and nothing else.
Here's what the code looks like for the header of a class.
#ifndef Context_h
#define Context_h
#include "Arduino.h";
class Context {
public:
Context() {Serial.begin(9600); Serial.println("I am alive");}
String getSelectedStateName();
int getSelectedStateId();
void setStateName(String name);
void setStateId(int id);
bool isSerialBufferNonEmpty();
int getSerialBufferSize();
char readCharFromSerial();
void printToSerial(String message);
private:
String _stateName;
int _stateId;
};
#endif
The point of the class is to allow state classes (i.e. that are part of the state pattern), to use it to send messages back to the main .ino script.
So I am curious, is it possible to use Serial within library classes?
thanks for reading!