Zumo32U4 library
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
Zumo32U4IRPulses Class Reference

Emits pulses of infrared (IR) light using the IR LEDs on the Zumo 32U4 Main Board. More...

#include <Zumo32U4IRPulses.h>

Public Types

enum  Direction { Left = 0, Right = 1 }

Static Public Member Functions

static void start (Direction direction, uint16_t brightness, uint16_t period=defaultPeriod)
 Starts emitting IR pulses. More...
static void stop ()
 Stops emitting IR pulses. More...

Static Public Attributes

static const uint16_t defaultPeriod = 420

Detailed Description

Emits pulses of infrared (IR) light using the IR LEDs on the Zumo 32U4 Main Board.

Timer 3 is used to generate a PWM signal, so this library might conflict with other libraries that use Timer 3. When the pulses are stopped, Timer 3 can be used for other purposes.

Pin A1 (PF6) is used to select which set of LEDs to turn on: the left-side LEDs or the right-side LEDs.

Pin 5 (PC6/OC3A) is used as a PWM output to turn the LEDs on and off.

This class does not do anything with the IR LEDs or detectors on the Zumo 32U4 Front Sensor Array.

Definition at line 24 of file Zumo32U4IRPulses.h.

Member Enumeration Documentation

◆ Direction

This enum defines the two different sets of LEDs that can be used to emit pulses.


The LEDs on the left side of the robot.


The LEDs on the right side of the robot.

Definition at line 30 of file Zumo32U4IRPulses.h.

Member Function Documentation

◆ start()

void Zumo32U4IRPulses::start ( Direction  direction,
uint16_t  brightness,
uint16_t  period = defaultPeriod 

Starts emitting IR pulses.

directionSpecifies which set of LEDs to turn on.
brightnessA number that specifies how long each pulse is. The pulse length will be (1 + brightness) / (16 MHz). If brightness is greater than or equal to period, then the LEDs will just be on constantly.
periodA number that specifies the frequency of the pulses. The interval between consecutive the rising edges of pulses will be (1 + period) / (16 MHz). The default value is 420, which results in a period very close to 38 kHz.

Definition at line 7 of file Zumo32U4IRPulses.cpp.

◆ stop()

void Zumo32U4IRPulses::stop ( )

Stops emitting IR pulses.

Timer 3 can be used for other purposes after calling this function.

Definition at line 74 of file Zumo32U4IRPulses.cpp.

Member Data Documentation

◆ defaultPeriod

const uint16_t Zumo32U4IRPulses::defaultPeriod = 420

The default frequency is 16000000 / (420 + 1) = 38.005 kHz

Definition at line 40 of file Zumo32U4IRPulses.h.

The documentation for this class was generated from the following files: