![]() |
|
[C] Make my own library in arduino IDE - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] Make my own library in arduino IDE (/showthread.php?tid=5189099) |
Make my own library in arduino IDE - UZHA - Mar 1, 2016 I want to make my code more elegant to get ekstra points from my teacher. So my plan is to use a seperet file for all my functions that I will need to use throughout the program. We are making an arduino which can calculate your BPM of your heart. So I have so far made one function and it's job is to get average of a list. here is my code!: Code #include "Helper.cs"Now that is so far my main code. This function is made in notepad++ and I want to use it as a library for my code: Code #ifndef Helper.csNow will this work or do I need to make the library inside the arduino IDE? Do I need to make classes for a library to work or is this fine? Note: I'm just a beginner at coding and please tell me if there is anything wrong with the code. * - Goodies - Mar 1, 2016 Where do I begin. PHP Code This won't work. list is an integer, not an array. counter in the for loop is re-declared but unintitialized. It should be initialized to 0, and really, it should be declared outside the loop depending on the language. PHP Code If you are passing an array, you want to pass the size as well. Also, because the name of the funciton is 'getAverage', I assume you want the average. PHP Code Call it with: PHP Code * - webdev77 - Mar 2, 2016 Just a thought as well, rename your files to the appropriate file extensions. Arduinos do not support C#. While technically it doesn't matter since it is just text files you are working with, I'd recommend making them header files or C source files. * - UZHA - Mar 2, 2016 So Goodie, if I then make this a PHP file then call #include"library_getAverage"(<- jusr random name), I will be able to use it in my program? Then after that I can just keep on adding functions as I go on coding for the arduino project? |