Support » Pololu Zumo Shield for Arduino User’s Guide »
6. Zumo Shield Arduino library
Our Zumo Shield Arduino library makes it easy to get started writing Arduino sketches to control your Zumo. A link to download the library and installation instructions can be found on the library’s GitHub page. The Zumo Shield Arduino library documentation provides detailed information about the library, and the library comes with several example sketches.
If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install this library:
- In the Arduino IDE, open the “Sketch” menu, select “Include Library”, then “Manage Libraries…”.
- Search for “ZumoShield”.
- Click the ZumoShield entry in the list.
- Click “Install”.
If this does not work, you can manually install the library:
- Download the latest release archive from GitHub and decompress it.
- Rename the folder “zumo-shield-arduino-library-master” to “ZumoShield”.
- Move the “ZumoShield” folder into the “libraries” directory inside your Arduino sketchbook directory. You can view your sketchbook location by opening the “File” menu and selecting “Preferences” in the Arduino IDE. If there is not already a “libraries” folder in that location, you should make the folder yourself.
- After installing the library, restart the Arduino IDE.
After you install the ZumoShield library, you can learn more about it by trying the included example sketches and by reading the Zumo Shield Arduino library documentation.
The Zumo Shield Arduino library includes the following parts:
ZumoMotors provides functions for PWM-based speed (and direction) control of the two motors on the Zumo with the onboard DRV8835 dual motor driver. On Arduinos with ATmega328P, ATmega168, and ATmega32U4 microcontrollers (which include the A-Star 32U4 Prime, Arduino Leonardo, Arduino Uno, and most older Arduinos), the motor control functions use hardware PWM outputs from Timer1 to generate pulse width modulation at a 20 kHz frequency. (See Section 3 for more details about the motor driver and its connections.)
If you accidentally soldered a motor to the Zumo Shield backwards (opposite the orientation indicated in the assembly instructions), you can simply call
flipRightMotor(true) to make the motors behave consistently with the directions in your code.
ZumoBuzzer provides functions that allow various sounds to be played on the buzzer of the Zumo Shield, from simple beeps to complex tunes. (See Section 3 for more details about the buzzer and Section 3.c for an explanation of the buzzer control jumper settings.)
ZumoBuzzer is fully compatible with the OrangutanBuzzer functions in the Pololu AVR C/C++ Library, so any melodies written for OrangutanBuzzer functions will also work with ZumoBuzzer functions.
ZumoReflectanceSensorArray provides a set of functions for reading reflectance values from a Zumo reflectance sensor array. See Section 2.c for more information on the Zumo reflectance sensor array.
This depends on QTRSensors. The ZumoReflectanceSensorArray class is a subclass of QTRSensorsRC. The functions provided by QTRSensorsRC can also be used on the ZumoReflectanceSensorArray class, and are documented in the Arduino Library for the Pololu QTR Reflectance Sensors document.
ZumoIMU provides functions for configuring and reading the inertial sensors on the Zumo Shield. See Section 3.d for more details about the inertial sensors.
The library also includes copies of several other Arduino libraries:
QTRSensors interfaces with Pololu QTR reflectance sensors. Since the Zumo reflectance sensor array has the same interface as the QTR RC reflectance sensors, the ZumoReflectanceSensorArray library uses QTRSensors to read the sensor array.
PololuBuzzer enables playing notes and songs on a buzzer. For boards based on the ATmega328P, this library uses Timer 2 and pin 3 (PD3/OC2B). For boards based on the ATmega32U4, this library uses Timer 4 and pin 6 (PD7/OC4D). This library will conflict will other libraries that use the same timer or pin.
Pushbutton provides a set of functions that are useful for detecting and debouncing pushbutton presses. While the most obvious application of this library is to work with the Zumo Shield’s user pushbutton on digital pin 12, this library can be used as a general-purpose library for interfacing many types of buttons and switches to an Arduino, even without a Zumo Shield.