Color Tracking (Hiwonder 7.5)
The robot uses the ESP32-S3 vision module to detect a red target and then adjusts its movement so it stays facing the target.
If you move a red ball or block left/right in front of the camera, the robot rotates in place to follow it.
Power on the robot. The buzzer beeps once and the RGB light turns white. When a red ball is placed in front of the ESP32-S3 vision module and moved, the robot rotates to follow the ball.
The vision module returns a detected block location (often something like x, y, and size). Your controller compares the detected center to the desired center of the image.
// Conceptual control loop // error = targetCenterX - detectedCenterX // angle = kP * error // speed can be small or zero (rotate-in-place tracking) errorX = targetX - detectedX; set_angle = mapErrorToAngle(errorX); set_speed = chooseSpeed(); Velocity_Controller(set_angle, set_speed, 0, SIMULATE_PWM_CONTROL);
In the Hiwonder example, the control update runs on a timer (periodic callback) so the robot keeps adjusting smoothly.