One of the most popular library used largely in Arduino is wire.h library its actually easy to use. The wire library is created on Object-Oriented C ++ class library, most Arduino user they are not familiar with the implementation details library.

Arduinos Library is usually stored in the \arduino-1.6.X\ libraries directory. Each library usually has an example inside of the folder, there are some example codes that users can quickly understand how the wire.h code library works.

Below are the simple arithmetic library, have the following functions.

The first return two number and the second function returns the difference between the two numbers. To test this demonstration we need to create a library named calculator, create a folder inside of the Arduino libraries named calculator then create a header file “calculator.h”.

Setup the source files calculator.cpp

Facilitating and understanding of the use of the library we need to build our example file, which has a demo named calculator_test,

Using the Arduino IDE, you will see some functions library and will be displayed as red, while others is are not, apparently the function name and the header file name and some macros to make the syntax shown in red color, actually it is handy to check for errors.

In order for us to implement this library to the IDE, you need to add a keyboards.txt calculator file folder inside the contents keyboards.txt follows.

As you can see above example, the class name or the file name written in the front KEYWORD1, the function name is written before KEYWORD2. As LITERAL1, to highlight the name of the macro definition, which is not related to the library, so empty. It should be noted that there is one and only one tab between the name and KEYWORD1, you cannot used space.

Write your own code library on Arduino
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *