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

difficulty
●●●●
time
a long weekend-plus
license
GPL-3.0
repo
repo ACTIVE20 stars

WHAT YOU’LL NEED

  • Electronic partsfull list with part numbers in the repo BOM
  • Dev board / microcontrollerruns the project firmware

Partner

Run your scrapers in the cloudThis build needs data collection that runs 24/7. Apify's free plan includes $5 in credits every month — no card needed.Try Apify free
1

COMPAREE VERDICT

This is a complete sorting pipeline — hopper vibrates bricks onto a belt, a camera captures each one, and a neural network classifier decides which bin it drops into. The model and all code are in the repository, and the documentation covers wiring, setup, and retraining. What is missing is the frame: no CAD, no drawings, no cut list. You will be designing the physical structure yourself, which is fine if you are comfortable with that kind of fabrication, but it is the single biggest gap between the repository and a working machine. The parts list is honest and detailed, but there is no published total — expect 400-500 dollars depending on what you already own. The stepper wiring and conveyor mechanics are not trivial, so this is not a first electronics project. If you have a big LEGO collection and the workshop confidence to build a custom frame and belt system, this is a genuinely useful build. If you need step-by-step CAD and cut files, you will be designing half of it from scratch.

NOT IN THE REPO

  • The trained classifier model (models/CLASSIFIER_MODEL.h5) ships with the repository and can be retrained on your own brick categories.
  • Python code for the Raspberry Pi, Arduino sketch for motor control, and a detailed parts list are all present.
  • No 3D files or frame drawings — you will need to design or improvise the physical structure, hopper, and conveyor yourself.
  • The author never published a total build cost; the parts list (Raspberry Pi, camera, Arduino, stepper drivers, motors, belts, rollers, vibrating feeder, power supply, bins) suggests roughly 400-500 USD.
  • GPL-3.0 licence: open for commercial use with source disclosure.
  • Documentation walks through hardware assembly, software setup, and model retraining, but assumes you know how to wire steppers and build a conveyor.

Can I build this?

Printnothing required
BuyRaspberry Pi, Pi camera, Arduino, stepper motors and drivers, conveyor belt and rollers, vibrating feeder, power supply, bins, frame materials (wood or aluminium extrusion), wiring and connectors
Toolssoldering iron, wire strippers, screwdrivers, saw and drill for frame fabrication, multimeter
Skillsintermediate electronics wiring, basic Python and Arduino, mechanical fabrication (designing and building a frame and conveyor system from a parts list)
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
Cost$$, roughly 400-500 USD, dominated by the Raspberry Pi, motors, stepper drivers, camera, and conveyor parts
SafetyMains voltage through the power supply. Keep fingers clear of the belt and moving parts during testing. Otherwise ordinary electronics care.

This build involves mains voltage — for adults comfortable with electrical work only.

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

Ultra-thin power bank that fits anywherePartner · Kickstarter
Ultra-thin power bank that fits anywhere

CORE POWER BANK S: 0.2" thin, 2.8 oz, 5000 mAh with 22.5W fast charging. Semi-solid battery, carbon fiber, IPX7 waterproof.

Learn more

Videos

I Built a LEGO SORTING MACHINE with a Raspberry Pi! #diy #lego ...

Gallery

https://img.youtube.com/vi/r78rIRVYsgY/maxresdefault.jpg
https://img.youtube.com/vi/tuIczAiV4_w/maxresdefault.jpg

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 full parts list in the repository README and order components (No single supplier or kit — you will be sourcing steppers, drivers, belts, and frame materials separately.)
  2. 2.Design or improvise the frame and conveyor structure(No CAD or drawings provided — you will need to plan how to mount the hopper, belt, camera, and bins.)
  3. 3.Follow the wiring guide to connect the Arduino, stepper drivers, and motors (Includes pinout diagrams for the Arduino and stepper connections.)
  4. 4.Set up the Raspberry Pi, install dependencies, and load the pre-trained classifier model (Python environment setup and model file placement are documented.)
  5. 5.Run the test script to verify camera capture and sorting logic before running a full batch (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

  • No frame CAD or drawings — you will be designing the physical structure, hopper mount, and conveyor yourself, which is the biggest time sink if you are not experienced with mechanical builds.
  • The author never published a total cost, so budget 400-500 USD and expect to adjust based on what you already own or can salvage.
  • Stepper wiring and driver configuration can be fiddly — if the motors do not move or move erratically, check your wiring against the pinout diagram and verify driver current settings.
  • 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?

The pre-trained model covers common bricks, but worn or rare pieces may misclassify. Retraining the model on your own images improves accuracy for those cases.

Do I need to design the frame from scratch?

No drawings are provided, so yes — plan how to mount the hopper, belt, camera, and bins. Wood or aluminium extrusion both work.

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

Throughput depends on your feeder tuning and belt speed. Expect several hours for thousands of bricks, faster than hand-sorting but not instant.

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 trained model ships with the project, and it can be retrained on your own brick categories. What would you sort first — by color, by type, or by set?

CompareeTEAM20d ago

Practical notes from our verification: the repository includes a detailed parts list and wiring guide, but no frame CAD or drawings — you will be designing that part yourself, which is the single biggest time sink if you are not experienced with mechanical builds. The pre-trained classifier model is in the repo and runs on a Raspberry Pi, and the documentation walks through retraining if you want custom categories. The author never published a total cost, but the parts list suggests 400-500 USD depending on what you already own. The Instagram demo shows the machine running, and the repository was active as of our check.

BrickSortingMachine

The creator built this machine to solve the universal LEGO problem: finding one specific piece in a bin of thousands. The repository documents the full pipeline from hopper to classifier, and the model ships ready to run.

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.