3.6. Proximity sensing

The Zumo 32U4 can detect nearby objects using the three proximity sensors on the front sensor array. The proximity sensors do not emit their own light; instead they are designed to detect 38 kHz infrared (IR) signals from emitters on the Zumo 32U4 Main Board.

The main board has four IR emitters:

  • The middle-left and middle-right IR LEDs are surface-mounted on either side of the Zumo, inside the tracks and between the wheels. They emit light to the left and to the right.
  • The front-left and front-right IR LEDs are meant to face towards the front, though you can play with the exact angle to see if it yields better results for your particular application. These LEDs are included, but they must be installed by the user, as described in Section 4.

The middle-left LED and the front-left LED are in series, so you must install the front-left LED in order to use the middle-left LED, and you cannot turn on one without turning on the other. Similarly, the middle-right and front-right IR emitters are in series.

Two AVR pins are used to control the LEDs: pin 5 (OC3A) is the proximity LED PWM pin, and must be driven high to turn on any of the LEDs. Pin A1 (19) is the proximity LED selection pin, and must be driven high or low to select which set of LEDs to turn on. If A1 is high, the right-side LEDs are selected. If A1 is low, the left-side LEDs are selected. (When A1 is an input, it can be used to read the battery voltage.) The brightness of the emitters can be controlled by adjusting the duty cycle of the PWM signal on pin 5.

Our example code operates the proximity sensors by transmitting pulses on both the left and right LEDs at six different brightness levels. For each sensor, it generates two numbers: the number of brightness levels for the left LEDs that activated the sensor, and the number of brightness levels for the right LEDs that activated the sensor. A higher reading corresponds to more IR light getting reflected to the sensor, which is influenced by the size, reflectivity, proximity, and location of nearby objects. However, the presence of other sources of 38 kHz IR pulses (e.g. from another robot) can also affect the readings.

You can also just read the proximity sensors without turning on any LEDs. This could allow the Zumo to detect the IR proximity sensors of other robots, or to detect commands from a typical IR remote.

Forward LED selection

The kit version of the Zumo 32U4 comes with two types of through-hole IR LEDs that can be installed to serve as the forward emitters. Both types of LEDs use the T-1 3/4 package, meaning they have a diameter of approximately 5 mm. Also, they both emit 940 nm light. The main difference between these LEDs is their viewing angle. The blue-colored LEDs have a relatively narrow viewing angle of 20°, which makes them better at illuminating objects far away. The clear LEDs have a much wider 50° viewing angle, which makes them better at illuminating objects that are not directly in front of the Zumo. The choice of IR LEDs to use is one way for you to customize your Zumo.

The assembled versions of the Zumo 32U4 robot ship with clear (wide-angle) LEDs installed; blue (narrow-angle) LEDs are not included with these versions.

IR LED holder

Note: Kits shipped before August 2015 do not include the LED holder and its mounting screws. Instead, the forward IR emitter LEDs can be shielded with shrouds made from the included heat shrink tubing as described below.

Proper shielding for the forward emitters is important; without shielding, light from the LEDs can activate the proximity sensors directly and cause false readings. The Zumo 32U4 comes with a plastic LED holder that serves to shield the LEDs while also holding them in place and helping to protect them from collisions with other robots. The LED holder screws to the blade with the two included 3/16″ #2-28 thread-forming screws. See the assembly instructions in Section 4 to learn how to properly install the forward emitters with the LED holder.

IR LEDs with LED holder.

Shielding with heat shrink tubing

You can make shrouds out of black heat shrink tubing to shield the forward emitters as an alternative to using the LED holder. Without the LED holder, the LEDs are less securely mounted, but you can more easily adjust their positioning.

IR LEDs with heat shrink shielding.

You can test to see if your shielding is good by putting your Zumo on a black surface with no objects nearby and making sure that you get a reading of 0 for all the proximity sensors.

3/16″ diameter heat shrink tubing can work well (tubing of this size was included with kits prior to August 2015), but please note that the actual diameter of heat shrink tubing often differs significantly from its nominal diameter, depending on the type and manufacturer of the tubing.

Proximity sensor performance

The proximity sensors have no particular minimum sensing distance; they can sense an object that is close to the Zumo as long as the shape of that object allows some light from the LEDs to be reflected into the sensor.

The maximum sensing distance depends on the size and reflectivity of the object you are sensing. We did several tests of the front proximity sensors to see how well they could see the steel blade of another Zumo while both robots were on the black surface of a sumo ring. In these tests, we found that the maximum sensing distance was around 30 cm to 40 cm.

There is a significant dead spot between the sensing regions of the front sensor and each side sensor. Therefore, if the Zumo senses an object with the left or right sensors and then turns to face it, there will probably be a period of time where none of the sensors can see the object.

Facing towards an object

The FaceTowardsOpponent demo found in the Zumo 32U4 Arduino library (Section 6) uses the motors and the front proximity sensor to scan for nearby objects, face directly towards them, and track them if they move. To directly face an object, it compares the two readings from the front sensor: the number of brightness levels for the left LEDs that resulted in the sensor activating, and the number of brightness levels for the right LEDs that resulted in the sensor activating. If the left reading is greater than the right reading, it means the object is closer to the left LEDs, so the robot should turn left (counter-clockwise) to face it more directly. Similarly, if the right reading is greater than the left reading, the robot should turn right (clockwise). If both of the readings are below a certain threshold, then it just turns the motors in order to scan for nearby objects.

This could be a good starting point for a sumo robot that uses the front sensors to locate its opponent.

Related Products

Zumo 32U4 Robot Kit (No Motors)
Zumo 32U4 OLED Robot (Assembled with 75:1 HP Motors)
Zumo 32U4 OLED Robot (Assembled with 50:1 HP Motors)
Zumo 32U4 OLED Robot Kit (No Motors)
Zumo 32U4 OLED Main Board
Zumo 32U4 Main Board v1.1
Zumo Windowed Blade (for 32U4/2040)
Zumo 32U4 Front Sensor Array
Zumo 32U4 Main Board v1.0
Zumo 32U4 Robot (Assembled with 100:1 HP Motors)
Zumo 32U4 Robot (Assembled with 75:1 HP Motors)
Zumo 32U4 Robot (Assembled with 50:1 HP Motors)
Zumo 32U4 OLED Robot (Assembled with 100:1 HP Motors)
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors