Zumo Lines

The Zumo Robot Shield can be fitted with a Reflectance Sensor Array that allows it to solve different line/maze style problems. The Zumo Shield libraries provide methods to help read values from the sensor array. Packages and installation instructions can be downloaded from GitHub and once installed the sensor library can be included from Sketch > Include Library.  The sensor array uses the QTR sensors and therefore their library must also be included (installed as standard).

Simple Border Detection

Start by creating an instance of the ZumoReflectanceSensorArray class with:

ZumoReflectanceSensorArray sensors(QTR_NO_EMITTER_PIN);

You will also need to define a QTR_THRESHOLD that suits the lighting conditions and border/surface contrast and an array for the sensor values.

#define QTR_THRESHOLD 1500
#define NUM_SENSORS 6
unsigned int sensor_values[NUM_SENSORS];

The number of sensors is 6 regardless of whether you have removed the 2nd and 5th sensors as described below. This is because we do not use the init method here to initialise the sensor array. For a border detection you can read the sensor values in the loop with:

sensors.read(sensor_values);

and then respond to them accordingly:

if (sensor_values[0] < QTR_THRESHOLD) {

Example

Line Following

To be completed. There are many ways that the sensors can be mapped for different purposes.  For line maze solving and sumo type situations you might choose to make the following modification leaving you with just the middle and outer four sensors.   This sensor arrangement would be configured with:

byte pins[] = {4, 11, A0, 5};
reflectanceSensors.init(pins, 4);

You will also need to declare an array that can be used to store sensor values ensuring that NUM_SENSORS equals the number of sensors in operation (see below).

#define NUM_SENSORS 4
unsigned int sensor_values[NUM_SENSORS];

You should then use the following command alongside some movement of the robot (programmeed or manual) to calibrate the sensors. During the calibration phase the robot should be moved across the dark and light areas of the robot arena.

reflectanceSensors.calibrate();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.