Go Down

Topic: Making selfmade functions includable in other projects. (Read 300 times) previous topic - next topic


In my work to control a CNC machine from a sketch running in an UNO with a stepper shield I have developed some useful functions. It would be nice to save the functions, one by one, and include them in other projects. Can You tell me the steps in the proper direction?
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.


Oct 09, 2018, 04:20 am Last Edit: Oct 09, 2018, 04:40 am by jremington
I "select block" and "cut" or "copy" the function from within the Arduino editor and paste the function text into any other text editor. In Windows, Notepad++ is hard to beat.

Save that to a file with a .c or .cpp extension (for example "function.c").

If it is in the directory with your Arduino .ino file, it will automatically show up in a new tab in the Arduino editor. Include function.c into a new sketch using
Code: [Select]
#include "function.c"


You do this by putting those generally useful functions in a library. Here is a tutorial:
Work through that tutorial and if you get stuck come back and we'll help you out.

Go Up