HE BUILT A MACHINE THAT SORTS LOOSE LEGO BY ITSELF USING A CAMERA AND AI

A machine that feeds loose LEGO bricks up a hopper, photographs each one, and sorts them into bins using a trained neural network — no human in the loop.

by BrickSortingMachine

FULL CAD BOM FIRMWARE DOCS

AutomationAI

Built withArduinoRaspberry Pi

difficulty
●●●●○
time
a long weekend-plus
license
GPL-3.0
repo
repo ACTIVE21 stars
1
Jump to section

COMPAREE VERDICT

This is a complete sorting pipeline built largely from LEGO Technic itself — a vibration feeder separates the bricks, a camera scanner photographs each one, a classifier decides the category, and a rotating slide drops it into the right bin. The software stack is on GitHub; the creator's blog publishes the DIY plans module by module, with BrickLink Studio files and a BrickLink part list (about 150 euros of LEGO). You bring the Raspberry Pi, camera, servos, an Arduino Nano and a few L293D motor drivers, and a trained model — none ships in the repository. The electronics list is being reworked and is marked untested, so expect some soldering and adaptation. If you have a big LEGO collection and enjoy tinkering, this is a genuinely useful build.

GOOD TO KNOW

  • —No trained model ships with the repository; the code expects you to provide a classifier model file (the creator describes a classification web service on his blog) or train your own.
  • —Python code for the Raspberry Pi and an Arduino sketch for the rotating slide are in the repo; the materials list is on the creator's blog and is marked untested while the electronics are reworked.
  • —The structure is built from LEGO; BrickLink Studio files, a BrickLink part list and module-by-module plans are published on the creator's blog.
  • —The only published cost is about 150 euros for the LEGO parts; the electronics (Raspberry Pi 5, camera, servos, Arduino Nano, L293D drivers) come on top.
  • —GPL-3.0 licence: open for commercial use with source disclosure.
  • —The blog walks through each LEGO module and the electronics; the repository README covers installing and running the software services. Training a classifier is up to you.

Parts to buy

8 items

From our check of the build. Exact quantities and part numbers are in the creator’s BOM.

  • LEGO parts from the BrickLink listabout 150 eurosFind
  • Raspberry Pi 5 with active coolerFind
  • Camera Module 3 WideFind
  • 27 W USB-C supplyFind
  • Two LEGO-compatible 270° servosFind
  • Arduino NanoFind
  • L293D motor drivers for 9 V LEGO motorsFind
  • Wiring and a bit of perfboardFind

BUILDS OF THE WEEK

Five open-source builds worth your weekend, every week.

Checked like this one: what’s really in the repo, what it costs, how hard it is. One email, unsubscribe anytime.

Can I build this?

Printnothing required
BuyLEGO parts from the BrickLink list (about 150 euros), Raspberry Pi 5 with active cooler, Camera Module 3 Wide, 27 W USB-C supply, two LEGO-compatible 270° servos, an Arduino Nano, L293D motor drivers for 9 V LEGO motors, wiring and a bit of perfboard
Toolssoldering iron and a bit of perfboard for the motor drivers, wire strippers, screwdrivers, multimeter, and a PC to run the vision and classification services
SkillsLEGO Technic building from published plans, basic electronics wiring and soldering, and comfort with Python, conda and running networked services; training a classifier if you do not have one.
Timea long weekend-plus — expect a day on the frame, a day on wiring and assembly, and another half-day on software setup and model testing
CostMid band: about 150 euros of LEGO parts per the creator's BrickLink list, plus a Raspberry Pi 5, camera, servos and other electronics.
SafetyLow-voltage electronics; keep fingers clear of moving parts during testing. The README warns that the services communicate without authentication or encryption, so run the machine only on a private network you control.

Build at your own risk. Projects involve tools, electronics and sometimes mains voltage — follow the creator’s safety notes.

Videos

LEGO Sorting Machine | Update #02 | Building a machine to sort my LEGO bricks

More builds like this

All projects

Gallery

img.youtube.com
img.youtube.com

Start here

Navigation into the creator’s own docs — we don’t rewrite the guide, we route you to the source.

  1. 1.Read the DIY build instructions on the creator's blog and order the LEGO parts and electronics (The LEGO structure comes from the BrickLink Studio files and a BrickLink part list (about 150 euros); the electronics are listed separately in the electronics article.)
  2. 2.Build the LEGO modules from the published plans(Follow the module guides (bulk storage, vibration feeder, scanner, sorting slide) and the BrickLink Studio files on the creator's blog.)
  3. 3.Wire the Raspberry Pi, Arduino Nano, servos and L293D motor drivers following the electronics article (The electronics article on the creator's blog lists the parts (Raspberry Pi, servos, Arduino Nano, L293D drivers for 9 V LEGO motors); the author marks it as not yet fully tested.)
  4. 4.Set up the conda environment, run the controller on the Raspberry Pi and the vision and classification services on a PC, with a classifier model you train or obtain yourself (Python environment setup and model file placement are documented.)
  5. 5.Start the controller with --disable_machine first to check the services talk to each other, then test with a small batch of bricks (Recommended to test with a small set of bricks first to calibrate camera position and bin alignment.)

Resources

Documentation, files and community threads for this build — we link straight to the original sources and never rehost the creator’s files.

KNOWN ISSUES

  • The plans live on the creator's blog, not in the GitHub repo, and the machine is built mostly from LEGO Technic. Follow the BrickLink Studio files and module guides rather than inventing your own frame.
  • The author gives a cost only for the LEGO parts (about 150 euros on BrickLink). Price the Raspberry Pi, camera, servos and other electronics yourself.
  • There is no off-the-shelf motor driver: the creator drives the 9 V LEGO motors with L293D H-bridges on perfboard, so expect a little soldering and some debugging of the GPIO wiring.
  • Camera position and lighting matter — if the classifier is misidentifying bricks, adjust the camera angle and add diffuse lighting to reduce shadows.
  • The vibrating feeder needs tuning to feed one brick at a time — too fast and bricks jam, too slow and throughput drops.
  • Model retraining requires collecting and labelling your own training images — plan a few hours if you want to add custom categories.

Can I use a different single-board computer instead of a Raspberry Pi?

Yes, as long as it runs Python and supports the Pi camera or a USB webcam. You may need to adjust the camera capture code.

How accurate is the classifier on unusual or worn bricks?

No trained model ships with the repository, so accuracy depends on the classifier you train or obtain and on your camera and lighting. The creator describes a classification web service on his blog.

Do I need to design the frame from scratch?

No. The creator publishes BrickLink Studio files and a BrickLink part list (about 150 euros of LEGO) plus step-by-step guides for each module on his blog.

How long does it take to sort a large bin of LEGO?

The creator does not publish a sorting rate. Throughput depends on how well the vibration feeder separates bricks and how fast your classifier runs.

Can I add more sorting bins?

Yes — update the category list in the code and retrain the model to recognise the new bins.

Community builds

No community builds yet — be the first, we feature the best ones.

Discussion1

FROM THE COMPAREE TEAM

The plans are published, but the classifier is yours to train. What would you sort first — by color, by type, or by set?

CompareeTEAM2mo agoedited

Practical notes from our verification: the machine itself is built from LEGO parts, and the author publishes DIY build instructions on bricksortingmachine.com — BrickLink Studio files, a BrickLink part list (about 150 euros), and guides for the vibration feeder, scanner and storage modules. The GitHub repository holds the software and an Arduino sketch for the rotating slide, but no trained model: the models folder only contains a placeholder, so plan to train or obtain a classifier yourself. The electronics list on the blog (Raspberry Pi 5 with Camera Module 3 Wide, two servos, an Arduino Nano, and an L293D driving 9V LEGO motors) is marked by the author as not yet tested. Some videos circulating under this name are from other creators' sorting machines; the author's own updates are on the BrickSortingMachine YouTube channel. Correction (4 October 2026): we re-checked this page line by line against the project's own repository, documentation and videos, and fixed errors in earlier versions.

BrickSortingMachine

BrickSortingMachine has been building a fully automated LEGO sorter since January 2022, inspired by earlier sorting machines. The software stack is on GitHub, and the blog publishes DIY plans for each module, with a community on Discord and YouTube.

GitHub

Star the project on GitHub

DISCLAIMER

  • Comparee is not the author of the projects featured here. All rights to each project belong to its creator — every page links to the original source, and we never host creators’ files.
  • Information is provided without warranty and may become outdated as projects evolve. Prices are indicative bands only — always check the creator’s parts list for current costs.
  • Building and operating any project is at your own responsibility. Protective equipment, safe workshop practice and compliance with local regulations are the builder’s responsibility.