Adding header and cpp files to Arduino folder

arduino m0 files header cpp

This example shows how to add more files (such as *.h and *.cpp) to a current Arduino project without making it into an Arduino library.

Example folder structure:

.
├── Makefile
├── main.ino
└── src
    └── foo
        ├── foo.cpp
        └── foo.h

Code

Download code
#include "src/foo/foo.h"

void setup() {
    SerialUSB.begin(9600);
    while (!SerialUSB) { }

    SerialUSB.println("Start!");
}
void loop() {
    bar();
    delay(2000);
}

Serial console

Serial output from the firmware.

Adding header and cpp files to Arduino folder serial console

References