Pages: [1]   Go Down
Author Topic: Guide to using Arduino libraries  (Read 1269 times)
0 Members and 1 Guest are viewing this topic.
Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.arduino.cc/en/Main/Libraries

Libraries provide your sketches with extra functionality (e.g. the ability to control an LED matrix, or read an encoder, etc.). They were introduced in Arduino 0004.

To install a library, place it in its own folder inside ARDUINO/lib/targets/libraries. It will then appear in the Sketch | Import Library menu in the Arduino IDE. To use a library in a sketch, select it from that menu while editing the sketch. This will insert at the top of the sketch an #include statement for each header file (ending in .h) in the library's folder. These statements make available to your sketch the functions and constants defined by the library. They also signal the Arduino environment to link that library's code (contained in files ending with .c or .cpp) with your sketch it is compiled or uploaded.

Because libraries are uploaded to the board with your sketch, they increase the amount of space used on the ATmega8 on the board. If a sketch no longer needs a library, simply delete its #include statements from the top of your code. This will stop the Arduino IDE from linking the library with your sketch and decrease the amount of space used on the Arduino board.

To get started writing libraries, download this test library (http://www.arduino.cc/en/uploads/Main/Test.zip). It should provide a basic guide for creating a new library.
Logged

Pages: [1]   Go Up
Jump to: