Problem in Blockly code for pick and sort


Hello Everybody,

I am working on an example where dobot picks and sort the dice. The dice are sent on the Conveyer belt. The problem currently that I#m facing is

  1. dobot pick up all the dice(red, green and yellow), puts it on the color sensor and sorts it(putting it some other location) except for the blue color. When dobot picks up the blue dice it puts it on the color sensor and later doesn’t move it away, it is always on the sensor. Could you please advice me if I’m going wrong anywhere or is there anyway to solve it.
  2. The sorting is not happening correctly.

Any kind of suggestions are appreciated.
thank you for your time :slight_smile:


Color sensor can only recognize three colors


Great, thank you very much for your response!!
That was my understanding too. the problem is when the blue color is placed on the color sensor, dobot does not pick it up from the sensor and place it aside like it does for red and green dice.
Also, could you please tell how does the sorting happens. I mean which function is used for sorting.
Many thanks for your time :slight_smile:


Q: What should I do if the color sensor doesn’t work or it can only distinguish one color?
A: 1) Check the present software firmware and the version of Dobot Studio whether they support the color sensor or not.
2) The distance between color sensor and wood bloks shouldn’t be too long or too short, it had better in the range of 5~10mm.
3) Check the pre-setting color sensor interface and the actual interface is consistent or not.
4) If the above mentioned methods are noneffective, you can operate the test program and check the running log on the right side. The color sensor should be replaced if the data is abnormal.

The color sensor only recognizes the three colors of rgb, and other color recognitions are placed by default to the position of the first placed block. I didn’t find that dobot does not pick it up from the sensor. If the third color is not recognized, it may be a color sensor failure. It can only be repaired or replaced. I will give you a blockly example here. Regarding the order I only set a blue position, the other two color positions have a placement interval.

Thanks and best regards.


Thank you very much for your response.
I check that the dobot magician supports color sensor.
I appreciate for attaching the code. I dint understand the initialisation as few terms used are in Chinese.
Do you one in English??
It will help in abundance


Hope it helps you!


Amazing!! thank you very much I wil try to execute the same and check slight_smile: Thank you very much once again


Hello DobotDZY,

May I know how did you create “getcoler” function, as it is not available in the blockly where few functions are already defined in Dobot Studio.
Thank you for your time!


Sorry, I found it myself :slight_smile:


Hello DobotDZY,

The blockly code that you have shared works great. But it doesn’t enter into the loop. It only executed once…
I am using conveyor belt in my program as well. Could you please check y code and tell me where I could change to make the program work effectively.

One more request do you have a python code for the same ?? If so can you please share.

Thank you for your time.


Please send me an email and I will send you the file.



You could Email at
I have questions related to Vision kit as I am currently working on it. I will write you in mail.

Thank you for your time :slight_smile: