Colour Sensor for sorting Project

Hello

I have a question. I have to sort Lego's by colour in school.

Which is the best Sensor to go with?

My biggest problem is that the Legos are shiny

Thanks for your help.

There's a number of RGB color sensors out there; last time I looked TCS34725 seemed to be popular and affordable. The chip itself I understand has been discontinued, but lasting stocks are probably still being sold. There's a good Arduino library for this chip/module, which can be communicated with over I2C.

I would not recommend the TCS3200 and similar 'color to frequency' sensors. These output a variable frequency and that tends to confuse people who are relatively new to Arduino/electronics.

Change the angles between the light source, the object and the sensor.

The really best sensor is a camera, but only together with a powerful controller for image processing (RasPi...).

For a school project I'd use a ESP32CAM, and KNN (K Nearest Known Neighbour) ML (Machine Learning) algorithm for color sorting.

Simple machine learning with Arduino KNN | Arduino Blog

If When you can figure how to hold each of the pieces in exactly the same place in order for the colour sensor to actually sense them, then you will also be able to hold them at the proper angle to avoid the shine. :sunglasses:

I would use the LEGO colour sensor. It is designed to do the job.

By the way it is not Lego's, that means belonging to Lego. Neither is it Legos, meaning many Lego. The LEGO company itself is very strong on that. As this is for school then your teacher should know this and correct your sloppy language, if he / she is any good.

Heh, heh. Teacher talking! :grin:

Are you sure? The perceived color of light reflected by an object depends very strongly on the color of the illumination.

Do they have to be sorted under ambient light? If not you could use LEDs to provide light in different colours, and measure the reflectance with a simple photodetector - eg a photoodiode.
By comparing the response under (almost monochromatic) red green blue illumination you would eliminate other variables such as shininess or orientation.

I'm sorry, I'm not that strong in speaking english

But thank you for your help

A fun way to do it (well, it's a question of taste) is with just a light dependent resistor (ldr) and an RGB LED. Shine red light on the lego and measure with the ldr how much light you get. Do the same with green and blue. Compare with the ambient light (which you read from the ldr when the RGB LED is off). From this you can get your r, g and b values telling the colour of the lego.

Well, you need another resistor to create the voltage divider. But this works.

Which is basically what @johnerrington said in #9...

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.