This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
arduino:libraryinstall [2010/02/11 18:17] ladyada |
arduino:libraryinstall [2012/05/11 21:29] ladyada [How to install libraries] |
||
---|---|---|---|
Line 17: | Line 17: | ||
{{http://www.ladyada.net/images/arduino/fatreadernoliberror.gif}} | {{http://www.ladyada.net/images/arduino/fatreadernoliberror.gif}} | ||
- | ===== Installing libraries ===== | + | ===== Whats in a library? ===== |
- | OK so now to the good stuff, how to download and install libraries. A library is a folder with some files in it, the files will end in **.cpp** (C++ code file) and **.h** (C++ header file). | + | A library is a folder with some files in it, the files will end in **.cpp** (C++ code file) and **.h** (C++ header file). |
+ | |||
+ | {{http://www.ladyada.net/images/arduino/nsslibrary.gif}} | ||
There may also be some **.o** files. The **.o** files are C++ compiled Objects. If you end up working on the library and modifying it, be sure to delete the **.o** files as that will force the Arduino IDE to recompile the modified **.cpp**'s into fresh **.o**'s | There may also be some **.o** files. The **.o** files are C++ compiled Objects. If you end up working on the library and modifying it, be sure to delete the **.o** files as that will force the Arduino IDE to recompile the modified **.cpp**'s into fresh **.o**'s | ||
- | Two optional files you may see are **keywords.txt** (this is a hints file to tell the Arduino IDE how to colorize your sketch and **Examples** folder, which may have some handy test-sketches. These will show up under the File->Examples->Library dropdown | + | |
+ | Two optional files you may see are **keywords.txt** (this is a hints file to tell the Arduino IDE how to colorize your sketch and **examples** folder, which may have some handy test-sketches. These will show up under the File->Examples->Library dropdown | ||
+ | |||
+ | |||
+ | {{http://www.ladyada.net/images/arduino/examplelibdropdown.gif}} | ||
+ | |||
+ | ==== Its important to remember! ==== | ||
+ | |||
+ | The structure of the library folder is very important! The **.c** and **.h** files must be in the 'lowest level' of folders. For example, you cant have **Arduino/libraries/WaveHC/WaveHC/file.c** or **Arduino/libraries/MyLibraries/WaveHC/file.c** - it must be **Arduino/libraries/WaveHC/file.c** | ||
+ | |||
+ | ===== How to install libraries ===== | ||
+ | |||
+ | In Arduino v16 and earlier, libraries were stored in the **ArduinoInstallDirectory/hardware/libraries** folder, which also contained all the built-in libraries (like Wire and Serial). | ||
+ | |||
+ | In v17 and up, the user libraries are now stored in the **ArduinoSketchDirectory/libraries** folder. You may need to make the **libraries** sub-folder the first time. However, the good thing about this is you wont have to move & reinstall your libraries every time you upgrade the software. | ||
+ | |||
+ | For example, here is how it looks when NewSoftSerial is installed in Windows (of course your username will be different) | ||
+ | |||
+ | {{http://www.ladyada.net/images/arduino/nsslibrarypath.gif}} | ||
+ | |||
+ | On a Mac, your arduino sketch folder is likely going to be called **Documents/arduino** so create a NEW FOLDER inside that called **libraries** and place the uncompressed library folder inside of that. | ||
+ | |||
+ | Check that the **Documents/arduino/libraries/MyNewLibary** folder contains the **.cpp** and **.h** files | ||
+ | |||
+ | After you're done, restart the Arduino IDE |