RoboticsPublished Paper27 citations

Pixy2 Color Tracking Robot

Published paper on color-based object tracking using the Pixy2 CMUcam5 camera and Arduino. 27-citation validation of educational robotics approach with sub-100ms latency.

doi.org/10.18196/jrc.26128
Full Citation
Implementation of a Camera Sensor Pixy 2 CMUcam5 to a Two Wheeled Robot to Follow Colored Object
Journal of Robotics and Control (JRC) · Vol. 2, No. 6, pp. 496-501 · 2021 · 27 citations

The Problem

Educational robotics platforms overwhelmingly use simple infrared (IR) sensors for line following and obstacle detection. While IR sensors are inexpensive and easy to program, they are limited to high-contrast surfaces and cannot generalize to the rich object-tracking scenarios that engage students — following a colored ball, intercepting a moving toy, or navigating toward a specific object in a cluttered environment.

Camera-based vision offers richer environmental perception, but integrating a camera with real-time image processing on a microcontroller like the Arduino Uno is challenging. The Arduino's 16 MHz ATmega328P cannot run OpenCV or perform frame-by-frame image analysis at usable rates. A dedicated vision co-processor is needed — one that can detect objects onboard and report only the results to the Arduino.

The Pixy2 CMUcam5 fills this gap. It runs color-based blob detection on its own processor at 50-60 Hz and communicates detected object coordinates over SPI or I2C. This paper demonstrates the complete integration: Pixy2 for vision, Arduino for control logic, and a differential-drive chassis for physical motion — all in an accessible educational package.

The System

The Pixy2 CMUcam5 detects color blobs using its onboard processor and communicates detected objects to the Arduino Uno via I2C at 50-60 Hz. Each detection packet includes the detected color signature ID, bounding box coordinates (x, y, width, height), and the center point of the detected object.

The Arduino normalizes the x-coordinate from pixel space (0-320) to a signed range (-1 to +1) using a linear mapping function. A dead-zone threshold of 0.15 suppresses jitter from small detection noise — if the normalized position falls within [-0.15, +0.15], the robot considers the target centered and moves straight forward.

Differential-drive control uses asymmetric speeds for turning: forward motion at 80 PWM on both motors, turning at +170 PWM on one motor and -80 PWM on the other (producing a pivot turn). An L298N dual H-bridge motor driver handles the high-current switching. The full sensor-to-motor control loop runs at approximately 16 ms per iteration.

The control law is proportional-only: motor speed = Kp * (normalized_x). There is no integral term to eliminate steady-state error or derivative term for damping. A referenced PIDLoop class exists in the accompanying codebase but is unused in the published tracking implementation.

System Architecture
1
Pixy2 Camera
Onboard color blob detection at 50-60 Hz via I2C
2
Arduino Uno
Normalize x-coordinate, dead-zone filter, compute motor PWM
3
L298N Motor Driver
Dual H-bridge, asymmetric PWM (forward 80, turn 170/-80)
4
DC Motors
Differential drive with two wheels + caster
5
Power
7.4V LiPo battery for motors, 5V regulator for logic

Results

The robot achieves reliable color-based object tracking at speeds up to 0.3 m/s with sub-100 ms detection-to-motor latency. The color-based method proved robust under varying indoor lighting conditions typical of classroom environments — fluorescent, LED, and mixed natural lighting.

As of 2026, the paper has accumulated 27 citations, primarily from other researchers adopting Pixy2-based computer vision for educational robotics platforms. The paper's contribution is not a novel algorithm but a validated integration recipe: which components to use, how to connect them, and what control parameters work in practice.

The dead-zone prevents oscillation when the target is centered, while asymmetric turn speeds produce sharp corrections when the target moves off-axis. This simple but effective control approach keeps the codebase under 100 lines of Arduino C++, making it accessible for students learning both robotics and programming.

Performance Metrics
~16ms
Loop time
50-60 Hz
Detection rate
27
Citations
0.15
Dead zone
0.3 m/s
Max speed

Implementation

The Arduino sketch (`coba_pixy_follow_try2.ino`) implements the entire control pipeline in under 100 lines. It initializes the Pixy2 over I2C, enters a continuous loop reading detected objects, normalizes the x-coordinate, applies the dead-zone, computes motor PWM values, and writes them to the L298N motor driver pins.

The proportional-only controller lacks integral and derivative terms, which limits tracking performance when the target moves at non-constant velocity. A PIDLoop class is referenced in the codebase as future work but was not used in the published results. The current implementation prioritizes simplicity over tracking smoothness — a deliberate trade-off for educational accessibility.

Future improvements could include adaptive thresholding for varying lighting conditions, multi-signature tracking (following the closest of several colored objects), and integration with a PID controller for smoother tracking at higher speeds.

View source on GitHubsigitdanip/pixy-robot\u2192