Loading...

Reference   Language | Libraries | Comparison | Changes

Libraries

Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch, select it from Sketch > Import Library.

Standard Libraries

  • EEPROM - reading and writing to "permanent" storage
  • Ethernet - for connecting to the internet using the Arduino Ethernet Shield
  • Firmata - for communicating with applications on the computer using a standard serial protocol.
  • LiquidCrystal - for controlling liquid crystal displays (LCDs)
  • SD - for reading and writing SD cards
  • Servo - for controlling servo motors
  • SPI - for communicating with devices using the Serial Peripheral Interface (SPI) Bus
  • SoftwareSerial - for serial communication on any digital pins
  • Stepper - for controlling stepper motors
  • Wire - Two Wire Interface (TWI/I2C) for sending and receiving data over a net of devices or sensors.

The Matrix and Sprite libraries are no longer part of the core distribution.

Contributed Libraries

If you're using one of these libraries, you need to install it first. To do so, download the library and unzip it. It should be in a folder of its own, and will typically contain at least two files, one with a .h suffix and one with a .cpp suffix. Open your Arduino sketchbook folder. If there is already a folder there called libraries, place the library folder in there. If not, create a folder called libraries in the sketchbook folder, and drop the library folder in there. Then re-start the Arduino programming environment, and you should see your new library in the Sketch > Import Library menu.

For details, see the page on the Arduino environment.

Communication (networking and protocols):

  • Messenger - for processing text-based messages from the computer
  • NewSoftSerial - an improved version of the SoftwareSerial library
  • OneWire - control devices (from Dallas Semiconductor) that use the One Wire protocol.
  • PS2Keyboard - read characters from a PS2 keyboard.
  • Simple Message System - send messages between Arduino and the computer
  • SSerial2Mobile - send text messages or emails using a cell phone (via AT commands over software serial)
  • Webduino - extensible web server library (for use with the Arduino Ethernet Shield)
  • X10 - Sending X10 signals over AC power lines
  • XBee - for communicating with XBees in API mode
  • SerialControl - Remote control other Arduinos over a serial connection

Sensing:

  • Capacitive Sensing - turn two or more pins into capacitive sensors
  • Debounce - for reading noisy digital inputs (e.g. from buttons)

Displays and LEDs:

  • Improved LCD library fixes LCD initialization bugs in official Arduino LCD library
  • GLCD - graphics routines for LCD based on the KS0108 or equivalent chipset.
  • LedControl - for controlling LED matrices or seven-segment displays with a MAX7221 or MAX7219.
  • LedControl - an alternative to the Matrix library for driving multiple LEDs with Maxim chips.
  • LedDisplay - control of a HCMS-29xx scrolling LED display.

These libraries are compatible Wiring versions, and the links below point to the (excellent) Wiring documentation.

  • Matrix - Basic LED Matrix display manipulation library
  • Sprite - Basic image sprite manipulation library for use in animations with an LED matrix

Frequency Generation and Audio:

  • Tone - generate audio frequency square waves in the background on any microcontroller pin

Motors and PWM:

  • TLC5940 - 16 channel 12 bit PWM controller.

Timing:

  • DateTime - a library for keeping track of the current date and time in software.
  • Metro - help you time actions at regular intervals
  • MsTimer2 - uses the timer 2 interrupt to trigger an action every N milliseconds.

Utilities:

  • PString - a lightweight class for printing to buffers
  • Streaming - a method to simplify print statements

For a guide to writing your own libraries, see this tutorial.

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.