Dividing code into multiple files

So I have written an Arduino sketch that is getting quite long, so I decided to move my functions into my own "library". Now I have no experience with creating libraries and in my functions I use functions from other libraries. This somehow doesn't work and even after playing around and moving variable initializations to the .h file I still get errors. I am using the FastLED.h library to control some Led strips. The FastLED library comes with initializations like "CRGB leds[NUM_LEDS];" . Now I am not sure in which file I have to include all the libraries and where to put the "CRGB leds[NUM_LEDS];" expression.

Welcome to the forum

Are you creating your own library or do you just want to move some of your code into different files (tabs in the IDE) to make it easier to manage ?

well actually yes. I only need to move my functions into other tabs or sketches. When I looked up how to divide your code up, creating a library is what I found

Move your functions into one or more separate .ino files in the same folder as the sketch and they will show up as tabs in the IDE

Try a single function first. Create a new tab in the IDE, give it a filename with an extension of .ino and move a function into it

The Arduino will combine all of the .ino files in the sketch folder into one big .ino file before compiling it

You are not creating a library by doing this

That works :slight_smile: . Thanks a lot.

Sounds good. Enjoy your new knowledge