Trying to understand how to import arduino code

Hi @pedante,

if you have the source code for your libraries, mozzie and bounce2, then you can either:

  • Put the *.cpp and *.h files into your src folder - not advised though;
  • Put the *.cpp files into src and the *.h files into include - better, but not the best solution;
  • Use the lib folder. This is sort of frowned upon these days, but works and saves having to mess with lib_deps and such like. :wink:

If you take the latter option, then within lib create mozzie and bounce2 then put the *.cpp and *.h files for mozzie into lib/mozzie. Likewise put the *.cpp and *.h files for bounce2 into lib/bounce2.

The format for the lib folder, or any library folder is:

lib
   mozzie
      mozzie.h
      mozzie.cpp
   bounce2
      bounce2.h
      bounce2.cpp

Each different library has it’s own separate folder within lib, containing all the files for the library. This is what I did in the “olden days” (about 6 months ago!)

With PlatformIO though, the recommended method is to install libraries into each project which uses them. This can be done on the command line using pio lib install "distributer/library_name" but most people I’ve dealt with here install from the platformio.ini file using the method I posed above, where you search for the library and follow the “installation” tab on the results page.

Have fun learning, and don’t be afraid to ask questions.

Cheers,
Norm.