Friday, March 2, 2012

Installing Arduino Libraries

System:

  • OS: MacOS X 10.7 (Lion)
  • Arduino 1.0
What I want to do:
I've downloaded this library for Arduino, and I need to "install" it - so I can use it for my sketches!
How:

  • Short version:
    • Copy the .cpp and .h files of that library in your Arduino/libraries folder.
  • Long version:
    1. Figure out where your Arduino folder is:
      1. Open the Arduino application
      2. Go to: Arduino > Preferences
      3. The first thing you'll see in that Preferences window is the "Sketchbook Location" - that's where your Arduino application will look for things (i.e. the libraries).
      4. The default is: "/User//Documents/Arduino". You can change it to wherever you like.
    2. Copy the library:
      1. Go to your Arduino folder (from Step 1)
      2. Create a folder called "libraries" (lowercase, no quotes) if there isn't already
      3. Copy the .cpp and .h files of your library into this libraries folder.
    3. Restart the Arduino application (if you have it open).
    4. Check that you can access your newfound library:
      1. In your Arduino application, go to: Sketch > Import Library
      2. Your library should show up under a subsection called "Contributed".

The library I'm using in this example is AFMotor. It's a motor control library to be used with the Arduino Motor Shield module. You can download it here: [Adafruit-Motor-Shield-library], and this is how to use/test it: [Motor Shield How-To].

Have fun!