Introduction
As a Lego enthusiast, I know firsthand how time consuming it can be to manually sort and organize a large collection of Lego bricks. Having an automated system to handle this tedious task would be a game-changer! In this guide, I'll walk you through the full process of building your own DIY electronic Lego sorter from start to finish using simple components like light sensors, motors, and microcontrollers.
Gathering the Required Electronic Components
The electronic components needed to build the Lego sorter include:
Light Sensor
- A light sensor module will detect the color of each Lego brick. Look for one with good sensitivity across the color spectrum.
Microcontroller
- A microcontroller like an Arduino or Raspberry Pi serves as the brain of the sorter. It processes the sensor input and controls the motors.
Motor
- A small DC motor with built-in gearbox provides the mechanical force to move each Lego piece into the correct storage container.
Motor Driver
- A motor driver translates control signals from the microcontroller into power sent to the motor. An L298N dual driver works well.
Power Supply
- A 12V DC power supply provides consistent voltage to the motors and electronics.
Jumper Wires
- Jumper wires connect all of the components together. Get male-to-female, male-to-male, and female-to-female versions.
Structural Components
Along with the electronics, you'll need these parts to build the structure:
-
Laser cut acrylic or wood for the main frame pieces. 3mm thickness works well.
-
3D printed parts for the motor mount, funnel, and any custom brackets. PLA filament is inexpensive and easy to use.
-
Lego bricks to build a launching mechanism and holding bins.
-
Screws, nuts and spacers to hold everything together. M3 size is a good fit for acrylic.
Assembly Steps
With all of the parts ready, it's time to put it together! Follow these steps:
1. Build the Main Frame
-
Cut the acrylic base, back, and side pieces to size according to your desired sorter dimensions.
-
Use corner brackets to join the pieces into a rigid frame.
2. Mount the Motors
-
Attach a motor to each storage bin, aligned above an opening where Lego bricks can drop in.
-
Use 3D printed brackets to secure the motor housings.
3. Install the Light Sensor
-
Mount the light sensor near the top of the frame, pointing downward at the scan point.
-
Carefully connect the sensor pins to the microcontroller.
4. Set Up the Microcontroller
-
Attach the microcontroller and motor driver to the inside of the frame.
-
Connect the jumper wires between the microcontroller, motor driver, motors, sensor and power supply.
5. Build the Launcher and Bins
-
Make a Lego launcher to automatically feed bricks onto the scan point one at a time.
-
Build Lego dividers and bins matching the number of motors for sorted storage.
-
Label the bins by color for easy identification.
Coding the Sorting Logic
With the hardware built, it's time to program the intelligent sorting logic. The key steps include:
Scan and Identify Brick Color
-
Activate the light sensor to detect the hue and intensity of light reflected off each Lego brick.
-
Compare the sensor readings to calibrated color profiles to identify the closest match.
Activate Matching Motor
-
Lookup the matching motor index based on the detected brick color.
-
Send a control signal to the corresponding motor driver channel to activate the right motor.
Return Motor Home
-
After a brief delay for the item to drop into the bin, signal the motor to reverse direction.
-
Run for an calibrated time to return the motor arm back to the home position.
Repeat Continuously
- Loop through the scanning and sorting process for each new Lego brick, operating continuously.
Conclusion
Building your own automated Lego sorter is a fun electronics project that also produces a useful tool to organize your bricks with ease. The key is getting the mechanical components aligned properly and coding reliable color detection and motor activation logic. With some persistence and testing, you'll be able to sort your Legos hands-free in no time!