[SOLVED] How to use additional files (.c and .h) with .ino file (Particle desktop IDE)

So I have a bunch of common functions that I want to break out into a re-usable class, but I don’t want to go through the pain of creating an official library and publishing it to the community (yet).

I have followed the tutorial here to get a basic grasp on how .c and .h file structure works;

So my project structure looks as follows;


Content of MyApp.ino

#include <MyFunctions.h>
MyFunctions morse(13);
void setup()
void loop()

Content of MyFunctions.h

#ifndef MyFunctions_h
#define MyFunctions_h
#include "Particle.h"
class MyFunctions
    MyFunctions(int pin);
    void dot();
    void dash();
    int _pin;

Content of MyFunctions.c

#include "Particle.h"
#include "MyFunctions.h"
MyFunctions::MyFunctions(int pin)
  pinMode(pin, OUTPUT);
  _pin = pin;
void MyFunctions::dot()
  digitalWrite(_pin, HIGH);
  digitalWrite(_pin, LOW);
void MyFunctions::dash()
  digitalWrite(_pin, HIGH);
  digitalWrite(_pin, LOW);

When I compile (in the cloud) I get the following error;

When I delete MyFunctions.h and MyFunctions.c and remove the line;

#include <Morse.h>

from MyApp.ino it compiles fine.

Learning C++ has it’s trips, but there seems to be additional layers of complexity/restrictions/rigidity due to the Arduino sketch format and the Particle platform which are not obvious nor trivial.

Can anyone please help out a n00b here?

EDIT : fixed formatting
EDIT2 : updated with first suggestions and corrected a few code mistakes

A couple of things I see wrong. You should be importing your file, not the class ( #include MyFunctions.h not #include Morse.h). You should also #include Particle.h rather than Arduino.h, and normally, the implementation file should have a .cpp suffix rather than .c (though, I don’t know if that matters).

1 Like

Thanks @Ric - there were some typos in my original post, so I have updated those and included your suggestions, getting the same compile errors though.

Well that did it! Changed the ‘MyFunctions.c’ to ‘MyFunctions.cpp’ and now compiles.

Thank you - really appreciate your help @Ric.