Skip to main content
I added code that compiles fine after fixing the typos.
Source Link
mpflaga
  • 2.8k
  • 2
  • 18
  • 19

First change your

#ifndef serialComms
#define serialComms

to

#ifndef serialComms_h
#define serialComms_h

You can not have a macro with the same name as an instance.

Then check you capitalization e.g. readBytes vs testing.readbytes(); notice the B


Make SURE you close out all your Arduino IDE's when making a NEW library directory and initial files with in it, for the first time. The IDE on startup caches a list of the files. They can subsequently change there insides. but new files will not be known until the next start.


The following compiles fine for me. Once I corrected all the typo's:

definetest.ino

#include <serialComms.h>
serialComms testing;

void setup() {
  Serial.begin(9600);
}

void loop() {
}

void serialEvent()
{
  testing.readBytes();
  testing.assignBytes();
}

serialComms.cpp

#ifndef serialComms_h
#define serialComms_h

/* serialComms Class */
class serialComms
{
  public:
//       serialComms() {};
void init();
void readBytes(); // Will be used to create the array --> two variables for now...
void assignBytes();
    };

#endif

serialComms.h

#include <Arduino.h>
#include <serialComms.h>

void serialComms::init()
{
  // This is where the constructor would be...right now we are too stupid to have one
}

void serialComms::readBytes()  // Target Pin,Values
{
  digitalWrite(11,HIGH);
  delay(250);
  digitalWrite(11,LOW);
  assignBytes();
}

void serialComms::assignBytes()
{
  for(int t  = 0;t<5;t++)
  {
    digitalWrite(10,HIGH);
    delay(250);
    digitalWrite(10,LOW);
  }   
}

First change your

#ifndef serialComms
#define serialComms

to

#ifndef serialComms_h
#define serialComms_h

You can not have a macro with the same name as an instance.

Then check you capitalization e.g. readBytes vs testing.readbytes(); notice the B

First change your

#ifndef serialComms
#define serialComms

to

#ifndef serialComms_h
#define serialComms_h

You can not have a macro with the same name as an instance.

Then check you capitalization e.g. readBytes vs testing.readbytes(); notice the B


Make SURE you close out all your Arduino IDE's when making a NEW library directory and initial files with in it, for the first time. The IDE on startup caches a list of the files. They can subsequently change there insides. but new files will not be known until the next start.


The following compiles fine for me. Once I corrected all the typo's:

definetest.ino

#include <serialComms.h>
serialComms testing;

void setup() {
  Serial.begin(9600);
}

void loop() {
}

void serialEvent()
{
  testing.readBytes();
  testing.assignBytes();
}

serialComms.cpp

#ifndef serialComms_h
#define serialComms_h

/* serialComms Class */
class serialComms
{
  public:
//       serialComms() {};
void init();
void readBytes(); // Will be used to create the array --> two variables for now...
void assignBytes();
    };

#endif

serialComms.h

#include <Arduino.h>
#include <serialComms.h>

void serialComms::init()
{
  // This is where the constructor would be...right now we are too stupid to have one
}

void serialComms::readBytes()  // Target Pin,Values
{
  digitalWrite(11,HIGH);
  delay(250);
  digitalWrite(11,LOW);
  assignBytes();
}

void serialComms::assignBytes()
{
  for(int t  = 0;t<5;t++)
  {
    digitalWrite(10,HIGH);
    delay(250);
    digitalWrite(10,LOW);
  }   
}
Source Link
mpflaga
  • 2.8k
  • 2
  • 18
  • 19

First change your

#ifndef serialComms
#define serialComms

to

#ifndef serialComms_h
#define serialComms_h

You can not have a macro with the same name as an instance.

Then check you capitalization e.g. readBytes vs testing.readbytes(); notice the B