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.)
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.
The library also includes copies of several other Arduino libraries:
L3G interfaces with L3G family of gyros. It makes it simple to read the raw gyro data.
LSM303 interfaces with the LSM303 family of 3D compass and accelerometer ICs. It makes it simple to read the raw accelerometer and magnetometer data.
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.