01 Color Recognition
01 Color Recognition
In this section, miniAuto will use the ESP32-S3 vision module to recognize red
and blue blocks. After the color is recognized, the RGB LED on the expansion
board will light up corresponding color, the buzzer will sound, and the miniAuto
will move accordingly.
1. Program Flowchart
1
3. Program Download
Note:
The Bluetooth module must be removed before downloading the program, otherwise
Please turn the switch of the battery box to “OFF” when connecting the Type-B
download cable in case the download cable touches the power pin of the expansion board
2)Connect the Arduino to the computer with the UNO cable (Type-B).
3)Click the “Select Board”, and the software will automatically detect current
Arduino serial interface. Then click to connect.
2
4)Click to download the program to the Arduino, and then wait for the
download to complete.
2) After flashing, disconnect the Type-C cable. Turn on the miniAuto to run the
program.
4. Program Outcome
1)After powering miniAuto on, the RGB light on the expansion board will light
up red when red is recognized. The buzzer will beep once. The robot car will
move forward and backward.
2)When blue is identified, the RGB LED will light up blue. The buzzer will beep
3
twice. The robot car will move left and right.
3)When the specified red or blue is not recognized, the RGB LED will light up
white.
5. Program Analysis
2) Next, the RGB light object was created to control the color of the RGB light.
The ESP32S3 vision module object is created to communicate with the
ESP32S3.
4
3) Initialize the RGB LED. Use the “Rgb_Show(255,255,255)” to set it to light
up white. Then, initialize the interface for ESP32-S3 and motor
communication.
4)Set the pin of buzzer to output mode. Stop activating the buzzer after a short
sound.
5
light is controlled to light up blue. If neither red nor blue is recognized, the RGB
light is controlled to light up white.
6. Function Extension
How to modify the recognized color of ESP32-S3 from blue to another color,
and make the RGB light on the expansion board light up the corresponding
color?
Take green as an example, please refer to the following instructions:
Locate the color recognition logic code in the program. Add an additional
condition “cam_buffer[2] == 2”, indicating green is recognized. The
“Rgb_Show(10,0,0)” function is used to display green.
6
After modifying is completed, refer to “3.1 Arduino UNO Program Download” to
download the program again.
7. FAQ
Q:Since the code was upload, the color can not be recognized.
A:Please check that you have connected the 4-pin cable to the I2C
interface.
Q:Why is the color recognized by the camera inaccurate or even incorrect?
A:Please try to minimize the complexity of the background. You can use a
single color or a simple environment as the background.