Welcome to K210 Module repository
3. 2DOF Fruit sorting
Fruit sorting
1. Experiment instructions
This experiment requires you to make a fruit sorter yourself
Firmware required for 24-channel servo driver board:K210-track.hex
The servo is connected to the 24-channel servo drive board and connected to the S1 pin of the servo control board.

Among them, the servo wire (the yellow wire is the signal wire, the red wire is VCC, and the black wire is GND) is connected to the corresponding color pin of the control board.
Please connect the 24-channel servo drive board to a 7.4V lithium battery pack, otherwise a low-voltage buzzer will sound.
The wiring diagram of the K210 vision module and the 24-channel servo drive board is as shown below.

Connect the serial port cable of K210 to the serial port interface of the 24-channel servo driver board(5V--5V, GND--GND, TX--RX3, RX--TX3)

2. Experimental goals
Learn how to use the K210 vision module with the 24-channel servo drive board to control the servo to perform fruit sorting function to complete the identification and sorting of apples and oranges.
3. Experimental operation
1、24-channel servo driver board firmware burning:K210-track.hex
2、Download the robot driver library robot_Lib.py and the model fruit_sort.kmodel in the CanMV\06-export\library directory in advance to the root directory of the memory card (you can also run the take_photo.py camera program and use the K210 vision module to take fruit photos to train your own Model)
3、Open CanMV IDE, open the fruit_sort.py code and download it to the K210 module
4、Connect the K210 module to the 24-channel servo driver board through the 4PIN cable
5、Turn on the power of the 24-channel servo driver board
6、When the fruit enters the collection range of the K210 module camera, the K210 module will frame the fruit and control the rotation of the servo.
4. Experimental effect
After the system initialization is completed, the LCD displays the camera screen. Use the camera to take a picture of the fruit. The screen will display the name of the detected fruit, and control the servo to rotate to an angle corresponding to the fruit to transport the fruit, and then return to the initial position of 90 degrees.
If an apple is detected, the servo will turn to the 40-degree position to transport the apple, and then return to the initial position;
If an orange is detected, the servo will turn to the 140-degree position to transport the orange, and then return to the initial position.