Libraries & Sketches...

I'm curious. If you open examples of libraries they have a header file (.h), and a c or c++ file (.c or .cpp). If you save a sketch, it saves it as a .ino file.

Would someone mind explaining to me what the difference is between the .h, .cpp, and .ino files in their usage? Also, why when you include a library in your sketch, do you only include the .h file instead of the .cpp file?

I'll explain.
.ino are your sketches, which include the setup and main program

Libraries are just a bunch of premade functions, objets, classes or structures, which are like "expansions" to your .ino projects. Libraries are not necesary if you include all this stuff in your main code (.ino), but then your coode will look much harder to look, they are very useful to orgainze your code and then you dont have to copy paste all the functions in other future proyects.

.h (also called header) is the declaration of all functions and classes, but without implementation.
.c or .cpp is the implementation of the functions/classes declared on .h
Then library contains both .h and .cpp, but .h includes .cpp on its file. That's why you dont have to call include any.cpp because it is already incorporated on any.h

Thanks for helping to clarify those things for me :slight_smile: