I am trying to create static methods in the class however I am getting this error:
":redefinition of 'class SerialFunc'".
would appericaite a code example/fix. attching my code:
+++++++++++++++++++++++++++++++++++++++++++++++++
class SerialFunc
{
public:
static void SerialSetup();
static void WriteToSerialPort(String txt,bool GoDownLine);
};
void SerialFunc::SerialSetup()
{
Serial.begin(9600); // Debugging output
Serial.println("serial start working");
}
void SerialFunc::WriteToSerialPort(String txt,bool GoDownLine)
{
if (GoDownLine==true)
{
Serial.println(txt);
}
else
{
Serial.print(txt);
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please post a complete sketch that shows the problem
The full messages will tell you where the declaration is and where the previous declaration was. You can find the messages in the text box below your sketch after you try to compile. You can select, copy, and paste the messages, just like copying text from a text editor.
I was recently caught out by something similar which may be worth checking. As part of ensuring that I had a working copy of a sketch that I was modifying I saved the working one, giving it a new name, but realised that I have not saved it where I intended, so I used Windows File Explorer to sort it out. Unfortunately I ended up with both the old and new .ino files in the same folder.
Only one showed up in the IDE that I had left open but after revising the code it would not compile due to a mass of "redefined variable" errors. Initially I assumed that the errors were caused by my revisions, but more careful examination of the full error messages, in particular the "first defined here" messages showed up what had happened.
So, is it possible that you have two tabs open in the IDE or a second .ino file in the same folder as the one that you are working on ?