Close
0%
0%

Colour sorting machine for Lego

Automatically sort random Lego pieces by colour!

Public Chat
Similar projects worth following
This promises to be my toughest project yet - a machine for automatically sorting Legos by colour: - random sizes and shapes - fast (at least one piece per second average) - compact (some other machines take up the whole room!) - no cameras, Raspberry Pi's or AI here! Just good, old-fashioned low-tech goodness. - minimalist design: as few moving parts as possible - low budget (something anyone can build at home)

The machine has eight basic functions:

  1. a hopper and chute to accept bulk Lego pieces of approximately the correct maximum size
  2. a drum feeder to extract a few pieces at a time for onward processing
  3. a vibratory feeder to help separate pieces from each other
  4. a 'slippery slope' feeder to encourage the pieces to stop tumbling and instead slide at a constant rate and constant orientation past the sensors 
  5. a 'light gate' sensor to detect the presence of an approaching piece
  6. a colour sensor (and light source) to measure the colour of a piece
  7. a microprocessor to perform a colour classification function, plus control the motors etc.
  8. a rotary diverter to guide the piece into the correct output bin

A key function of the machine, and something which is critically important to reliable sorting, is to tease apart pieces from each other, and separate them sufficiently that they can be diverted into different bins if necessary. Otherwise two or more might end up (incorrectly) in the same bin. This separation function is performed in three ways:

  • The drum feeder only scoops a few pieces in each bucket, and the bucket is curved so that pieces are released slowly, not all at once. The drum feeder sets the overall processing rate too.
  • As the pieces drop onto the vibratory feeder, partly helped by a sloping ramp, they are scattered along its length somewhat.
  • The vibratory feeder is designed to vibrate with an amplitude sufficient to make the pieces 'dance' about, not just move them along. Also it vibrates only a little at the uphill end, and much more at the lower end, so that pieces further along therefore tend to 'dance' more and accelerate towards the sensor, spreading them apart as they go.

The RGB value from the colour sensor is matched to one of 30 or so distinct Lego brick colours (determined by measuring a reference set of bricks). Each matched colour has an output bin number associated with it, so that e.g. all the different greens go in the 'GREEN' bin.

Finally, the diverter is designed to be short and have very low mass (low inertia). It limits the overall machine throughput because it determines a) how long a piece takes to transit between sensor and output bin, and b) how quickly it can move around to the next bin if required.

vee_channel_vibrator_mount_large_v2.stl

larger mount to take a 280 motor

Standard Tesselated Geometry - 104.96 kB - 07/06/2025 at 13:40

Download

controller_case-Rear.stl

Case (rear) for the screen

Standard Tesselated Geometry - 727.43 kB - 07/06/2025 at 13:39

Download

controller_case-Front.stl

Case (front) for the screen

Standard Tesselated Geometry - 765.32 kB - 07/06/2025 at 13:39

Download

drum_feeder_scoop_v3.stl

latest (smaller) scoop design

Standard Tesselated Geometry - 4.57 kB - 07/06/2025 at 13:38

Download

PDQ_ILI9341_config.h

header file to accompany Lego_display.ino

h - 2.40 kB - 07/06/2025 at 13:38

Download

View all 20 files

  • 1 × NEMA 17 stepper motor model 17HS3404-Z
  • 1 × A4988 stepper driver module
  • 1 × TCS34725 colour sensor module
  • 1 × Arduino Nano or compatible clone
  • 1 × small dc motor (e.g. "280" size) for vibe feeder

View all 14 components

  • Latest video

    RobG07/06/2025 at 13:33 0 comments

  • More updates and improvements

    RobG07/06/2025 at 13:27 0 comments

    The drum scoops are redesigned to be smaller so that fewer pieces are dropped each time. Also I've gone back to six scoops instead of twelve, which leaves gaps between the scoops which is useful when there are only a few bricks left in the drum. 

    Here are just a few of the scoop designs I've tried along the way: 

    Also, after much coding, a bit of soldering, and the design and print of a case, the TOUCH CONTROLLER! 

  • Updates!

    RobG06/07/2025 at 17:26 0 comments

    So it's been a while since the last log, and the machine has had many outings to school STEM events and the like. It has mostly worked really well, and got lots of interest and sparked lots of discussion - which was the whole point.

    However, I've had some ideas for improvements. Some of those were implemented today:

    - swapped out the vibrator motor for a larger one (a "280") since the original one got pretty warm and wore out too fast.

    - added control of the stepper driver's nENABLE pin so that the stepper current can be switched off between moves to save power and stop it getting too hot. I think the shaft was previously getting so hot the 3D-printed PLA part attached to it actually melted slightly.

    - added serial commands to start/stop the machine, adjust motor speeds, and read out a count of bricks in each bin.

    The last item is there so that in the near future I can put together a touch-screen controller with a real-time display of brick counts, plus the option to tweak the speeds, stop it if there's a problem, etc. Watch this space...

  • Ready for first demos

    RobG06/16/2024 at 06:14 0 comments

    A bit more tidying up, addition of a hopper and chute to load Legos into the drum, some fine tuning of the angles and software and it's done!

    It's not perfect but it is really fun to watch. The main remaining issue is that the scoops inside the drum sometimes pick up quite a few pieces, which then overwhelm the vibe feeder and they end up tailgating each other past the sensor. Something to tweak later. I'd also like to add a touchscreen with start/stop buttons and some readouts of brick counts, speeds, etc. Other ideas in the comments please! 

  • It's alive!

    RobG05/23/2024 at 06:10 0 comments

    First time putting together all the parts:

  • Coming together now

    RobG05/20/2024 at 07:17 0 comments

    I've chopped up something like 2.5metres of 2020 aluminium extrusion and turned it into a more permanent, more rigid frame for the drum feeder, vibration feeder and sensor head:

    The drum is belt driven from a DC motor/reducer gearbox running at about 200rpm. I needn't have worried about the belt wandering off the drum - it's absolutely fine, without any need for additional guides or track to keep it centred. 

    Everything's adjustable - angles, clearances, etc. - so the next steps are to do some tuning to get it feeding reliably and quickly, before finally integrating it with the diverter and output bins.

  • Drum feeder (2)

    RobG05/13/2024 at 08:08 0 comments

    The drum feeder is looking good now. After a bit of trial and error making paddles/scoops from card I've committed to a 3D printed design that works well enough for a first attempt. Physically positioning all the various parts was getting really tricky using the wooden lash-up so have also started the 'finished' build in 2020 profile and M5 fittings.

    I think I'll try a belt-drive to power it, from a DC motor and reducing gearbox. Only problem with a belt is that the drum has a slight draft to the sides, meaning that the belt will undoubtedly tend to wander off...

  • Drum feeder (1)

    RobG05/08/2024 at 20:12 0 comments

    So after a long break to get some other projects finished, I'm back to the Lego sorter and its drum feeder. 

    It may look like a food container, sat on some rollers, and with a hole in the lid, but it's much more than that! Actually, not really. That's exactly what it is.

  • Adding a motor controller

    RobG02/17/2024 at 16:05 0 comments

    Using a bench supply to control the current (and therefore speed/vibration frequency) of the vibrating feeder was getting a bit annoying, so I finally took the plunge and added an H-bridge driver and PWM control. Initially I tried an L9110S-based module (very cheap on the 'bay) but it wasn't up to it and kept overheating. Plus it doesn't support 'coasting' so ended up being quite noisy and inefficient.

    I swapped it out for an L298N-based module (almost as cheap) which is much better. By driving the ENABLE line with PWM, and holding the IN1/IN2 inputs H/L for fixed direction, it's possible to employ coasting, which keeps the motor happier.

    However, the Arduino's built in PWM frequency (977Hz) is very noisy, and changing the prescaler to get other values is no better (3.9kHz is also noisy, 31kHz is too fast for the driver). So ended up with a bit of code to set it at about 15kHz, which is perfect. Pretty much silent (to my deaf ears anyway) but with smooth power control and no overheating.

    Plus, the L298N has dual outputs, so I've still got a spare channel I can use to control the drum feeder's motor, when I get to that stage.

  • Vibrating feeder first try

    RobG01/26/2024 at 12:51 0 comments

    After quite a lot of trial and error on the feeder, I've settled on a design where one end is a hinge, forcing the vibrating motion to be confined to up-down only, and with low amplitude at the hinge end, and a large amplitude at the free end. It seems to work well at separating parts as long as there aren't too many at once:

    Obvs this is a dirty quick prototype using scraps lying around, I'll do a neat version one day out of profile aluminium...

View all 19 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates