How to Build an Arduino Library

Christian just shared a new tutorial: "How to Build an Arduino Library"

Have you ever wanted to simplify or automate a task using an Arduino? Yes? Well, have you ever wanted to simplify the code required for that task into a neat collection of easy-to-use functions? Also yes? Then this tutorial is for you! In this tutori…

Read more

Like this Tutorial a lot. Just to be clear are .h and .cpp files similar/same as subroutines as includes in say PIC basic? … in which I am very familiar.

Hi Michael,

I don’t have much PIC experience, but it seems that an Include serves a similar purpose as an Arduino Library.

Hi, fantastic tutorial.
Can you please advise on how to modify/update the myFirstLibrary in arduino IDE? ie if I made a small change to the source file and need to run the modified library?
Here’s what I’ve done
Firstly I edited the source file (I added Serial.print commands to simulate LEDs)
I opened example 1, added tested each function, worked beautifully.

Afterwards I edited the source file, added a delay(500) to the on() and off() function.

here I became stuck, I couldn’t add the new zip because it had the same name as the one before, I tried deleting and rezipping the modified library, still the same problem, I am unsure on how to delete the previous library in the IDE…

I can’t figure out how to update the to view this small change.

Is there a simple solution that I have overlooked?

Thanks in advance, you guys are legends


Hi Mitch,

I’d recommend to update the source and header files outside of the Arduino libraries directory (/Users/User/Documents/Arduino/libraries) and to use a text editor such as Atom or VSCode instead of the Arduino IDE. If the Arduino IDE is open it is unable to update it’s external libraries for use so make sure to close it before you move the new ‘myFirstLibrary’ folder (not a zip) into the Arduino Library directory or to close it after you import it from a .zip file.

Hope this helps,

Thank you so much Christian, now I can continue playing with libraries :smiley:

Followed yourTutorial rigorously but came unstuck after zipping myFirstLibrary and sticking in IDE successfully Not found afterwards in the drop down menus?

Does anyone have a .ino example I could use to get started, please?

Followed tutorial all the way to ‘make examples’. I know it seems silly, but this tutorial should have given an example of ‘make example’ to see how the function is supposed to work, syntax and all. Just one more paragraph would do it. :slight_smile: