https://www.raspberrypi.org/blog/raspberry-pi-lego-sorter/ * Skip to main content * Skip to footer * Accessbility statement and help * Hardware Low-cost, high-performance Raspberry Pi computers and accessories Buy Raspberry Pi 4 Buy Raspberry Pi 400 + All products + For industry + Documentation + Forums * Software Everything you need to get started with your Raspberry Pi computer Our software + Raspberry Pi OS + Raspberry Pi Desktop + Help + Forums * Books & magazines Books and magazines from Raspberry Pi Press Explore our titles + The MagPi + HackSpace + Wireframe + Custom PC * Learn Free resources for young people to learn to code and become digital makers Learn at home + Guided coding projects + Learn at a Code Club + Learn at a CoderDojo * Teach Free training, resources, and guidance to help you teach computing with confidence Support for teachers + Teach Computing + Start a Code Club + Online training courses * Forums * About us We work to put the power of computing and digital making into the hands of people all over the world About us + Donate + Support us + Our supporters + Blog Raspberry Pi Blog All blog posts * Archive * RSS Raspberry Pi LEGO sorter [WhatsA] * 19th Jan 2021 * Ashley Whittaker * 9 comments Raspberry Pi is at the heart of this AI-powered, automated sorting machine that is capable of recognising and sorting any LEGO brick. And its maker Daniel West believes it to be the first of its kind in the world! Best ever This mega-machine was two years in the making and is a LEGO creation itself, built from over 10,000 LEGO bricks. [vlcsnap-2020-11-28-07h42m46s176-800x711]A beast of 10,000 bricks It can sort any LEGO brick you place in its input bucket into one of 18 output buckets, at the rate of one brick every two seconds. While Daniel was inspired by previous LEGO sorters, his creation is a huge step up from them: it can recognise absolutely every LEGO brick ever created, even bricks it has never seen before. Hence the 'universal' in the name 'universal LEGO sorting machine'. Hardware [vlcsnap-2020-11-28-07h44m46s404-800x450]There we are, tucked away, just doing our job * Raspberry Pi 3 Model B+ * Raspberry Pi Camera Module V2 * 9 servo motors (controlled through a servo multiplexer communicating with the Raspberry Pi on I2C) * 6 LEGO motors (controlled through L298N motor controllers using digital I/O ports on Raspberry Pi) Software The artificial intelligence algorithm behind the LEGO sorting is a convolutional neural network, the go-to for image classification. What makes Daniel's project a 'world first' is that he trained his classifier using 3D model images of LEGO bricks, which is how the machine can classify absolutely any LEGO brick it's faced with, even if it has never seen it in real life before. We LOVE a thorough project video, and we love TWO of them even more Daniel has made a whole extra video (above) explaining how the AI in this project works. He shouts out all the open source software he used to run the Raspberry Pi Camera Module and access 3D training images etc. at this point in the video. LEGO brick separation The vibration plate in action, feeding single parts into the scanner Daniel needed the input bucket to carefully pick out a single LEGO brick from the mass he chucks in at once. This is achieved with a primary and secondary belt slowly pushing parts onto a vibration plate. The vibration plate uses a super fast LEGO motor to shake the bricks around so they aren't sitting on top of each other when they reach the scanner. Scanning and sorting A side view of the LEFO sorting machine showing a large white chute built from LEGO bricksThe underside of the beast A Raspberry Pi Camera Module captures video of each brick, which Raspberry Pi 3 Model B+ then processes and wirelessly sends to a more powerful computer able to run the neural network that classifies the parts. The classification decision is then sent back to the sorting machine so it can spit the brick, using a series of servo-controlled gates, into the right output bucket. Extra-credit homework A front view of the LEGO sorter with the sorting boxes visible underneathIn all its bricky beauty, with the 18 output buckets visible at the bottom Daniel is such a boss maker that he wrote not one, but two further reading articles for those of you who want to deep-dive into this mega LEGO creation: * How I created over 100,000 labeled LEGO training images * A high-speed computer vision pipeline for the universal LEGO sorting machine Share this post * Post to Twitter * Post to Facebook * LEGO * artificial intelligence * Image classification Related posts [architects] A history of Raspberry Pi in LEGO [trash-01-1] Classify your trash with Raspberry Pi [Raspberry-] Colour sensing with a Raspberry Pi [SORTING_HA] Sorting Hat Lesson Previous Post [OB260444-1] Deter burglars with a Raspberry Pi chatbot Share this post * Post to Twitter * Post to Facebook 9 comments Jump to the comment form Avatar Niels 19th January 2021, 11:04 am This is SO IMPRESSIVE. It looks like a lifetime project, but the maker isn't that old yet and has finished it already! Reply to Niels Avatar Stefan Misch 19th January 2021, 11:24 am I wonder if I can borrow this machine for a few days. Reply to Stefan Misch Avatar Langerosso 19th January 2021, 2:22 pm I NEED THIS NOW!!!!! This is just amazing. Cool project. Reply to Langerosso Avatar Justin Simms 19th January 2021, 2:49 pm Jacques Mattheij built something like this four years ago: https://jacquesmattheij.com/sorting-two-metric-tons-of-lego/ Reply to Justin Simms Avatar P 19th January 2021, 6:10 pm Which is also mentioned a few seconds into the video. Reply to P Avatar foo 19th January 2021, 2:52 pm Impressive! I wonder if would be possible to create a "LEGO sorter Zero", to classify images without human supervision, just watching different images of the bricks. Reply to foo Avatar Baraka 19th January 2021, 3:17 pm What about a machine to get the pieces of a desired set from the available stock? :) Reply to Baraka Avatar James Carroll 19th January 2021, 3:38 pm Such wonderful engineering. Reply to James Carroll Avatar Will 19th January 2021, 7:18 pm Great project! Any idea what the chances are of it making a mistake? Reply to Will Leave a Comment Name (Required) [ ] Email address (also required) [ ] Website URL [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] Your comment (required) [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] Submit About Us * About us * Our team * Governance * Safeguarding * Research * Jobs * Contact us Support * Help * Documentation * Projects * Training * Software * Forums * FAQ Sign up to our newsletter [ ] [ ] Subscribe * Like Raspberry Pi on Facebook * Follow Raspberry Pi on Twitter * Join us on Instagram * Subscribe to the Raspberry Pi YouTube channel Raspberry Pi Foundation UK Registered Charity 1129409 Accessibility Privacy Cookies Trademark rules and brand guidelines