Introduction: LEGO Boost Candy Sorter
This project is a LEGO-based reimplementation of an existing Arduino candy sorter project. Building with LEGO block-units made this a challenge, but programming and debugging the LEGO Boost via the app is much easier compared to Arduino.
The sorter goes through a loop of movements and events to sort candy:
- the swivelling plate picks up one candy by moving the hole under the feeder tube
- It turns to move that candy under the color sensor.
- The color sensor sees the color, and a slide rotates so that the candy will fall in the correct color zone or bucket.
- The plate turns to bring the candy to the drop location, where the floor ends and the slide begins.
- The slide turns back to its initial position
Throughout this build, colors don't matter. We used bricks from our spare collection, with no record of which LEGO set they once belonged to. The notable exception being the LEGO Boost main block, external motor and external color sensor. One exception in terms of color: the region around the color sensor is intentionally white, so the color detection of the candy is not disturbed by the surrounding LEGO bricks.
Let's get started.
Step 1: Swivelling Transport Plate
Get the parts
Get the following parts (as seen in the first picture). The slopes should be white, the other parts can be any color. The hole in the small Technic block is not a regular hole, rather one that doesn't allow the axle to turn (as seen here on bricklink ) That will be crucial later.
Assemble the parts
Assemble the parts (second picture). This plate will be swinging back and forth to transport candy from the supply to the color sensor, to the sorting ramp, and then back to its starting position to pick up the next piece of candy. Only the wheel part sticks out on the top. We didn't have a wheel attachment with height one. In the final machine, it didn't look like the wheel was actually doing anything, so you can probably do without. I just wanted to make sure the swivelling plate doesn't touch the floor when it turns.
Step 2: Technic Gear Assembly
Get the parts
N.B. the bevel gear pictured is a 12-tooth version. This part was introduced in 1995. An earlier 14-tooth version as introduced in 1980 would work just fine. Whatever version you use, you'll need a matching gear later in the build.
The holes in the 1x6 Technics brick aren't used in the build, so you can use a regular brick instead.
The length of the axle we used was 10 studs. A bit shorter may be enough. (Cfr. second picture)
Assemble the parts
As seen in the third picture.
Join both pieces together
As seen in the fourth picture. The swivelling plate doesn't need to touch the grey Technic rectangle. The axle should extend a bit beyond the swivelling plate. The axle will rest in a hole in the floor of the complete build.
Step 3: Prepare the Connection to the Motor Block
get an axle and another bevel gear. The blue piece is there as a reference for the length of the axle (but will be used in the next step). Remember to match the bevel gear type to the earlier one.
Assemble and get more parts
The grey axle goes through the middle hole, just enough to slide through the bevel gear. Make sure it doesn't touch the perpendicular black axle.
The spacer goes onto the grey axle, and the length 3 pins go on either side. Assemble the next four blocks and get a 16 tooth gear.
Join the new part on the previous one. The new part sits at spacer distance from the old part, connected by the length 3 pins and the axle. Slide the gear onto the grey axle where it protrudes from the new part.
Step 4: Decoration
This step is optional, as it was purely decorative. I created two minifigs that look a bit like my children, gave them a tablet in their hands (a decorated 1x2 tile with buttons and dials). I mounted them on a small plate attached on top of the long black axle so they turn back and forth as the sorter is working.
We displayed and demoed the sorter at the CoderDojo Belgium Coolest Projects fair in 2018. Decoration makes for entertained viewers!
Step 5: Build the Raised Structure
Build the structure
With assorted (and mostly regular) bricks, we're building the structure that will hold the mechanism up and provide the floor for the candy mover. The black block pictured will be one of the legs on which the structure stands. Only one special block is used here: a simple 1x2 brick with one hole. This is where the axle from the previous part will pivot. The hole is only one unit deep, underneath is a regular brick.
Attach the previous part
The third picture shows how the previous part is attached to the new one. You can see the first leg extending "down".
You'll see that the swivelling plate can turn freely around the black axle, and the 16-tooth gear can drive that motion via the perpendicular bevel gear.
Step 6: Add a Second Leg
We extend the large standing structure of the sorter, starting with another leg. We used two short yellow plates on top of a black 2x10 plate to provide support for the slide assembly (which you will build later). Three plates have the same thickness as a standard brick, so that simplifies the overall construction.
Attach the second leg as shown in the second picture.
Step 7: Extend the Floor
We extend the raised floor of the structure. This floor is two units thick throughout. Color choice is arbitrary except for the white blocks. In the area around the color sensor, we've selected white bricks to avoid influencing the Boost color sensor.
The second picture shows where to attach the floor extension.
Step 8: Build the Rotating Mechanisme for the Slide
Build around the external motor
The rotating slide will guide the candy to the correct color bucket. The external motor is the first Boost part we'll integrate. We add a couple of Technic parts to fix the motor to the rest of the structure even better. The axle goes through the first hole, the pin through the second.
The slide attachment
We continue with two double-perforated 1x2 bricks and a double pin of length 3, as shown in the fourth picture. If you only have one double-perforated 1x2 brick, that's OK. The slide attaches to only one of these.
Step 9: Build the Slide
The slopes are standard two-units-wide, one-unit-high slopes. The black end slopes are six studs long and tapered, which allows the slide to turn closer to the raised floor of the construction.
Two 1x8 plates extend from the main plate by 1 unit, and avoids the slide tilting down too much when it doesn't make contact with the bottom of the raised floor altogether.
The slide attaches to the axle using a pivot. We found this 2x2 pivot plate, but the 1x2 versions are more common and would work as well.
Slide and motor get attached to the legs of the structure, and this is where the 2 yellow plates on one of the first legs come in. The long perforated beam we attached to the front of the external motor fits perfectly on those two plates.
Step 10: Add Another Leg and More Floor Space
The next leg is built from standard Lego bricks. No Technic elements, no plates, no narrow beams, just bricks.
This leg gives the structure a fourth point of support to stand on.
Extend the floor
More regular bricks to extend the raised floor (third and fourth picture).
We can now turn the structure upright for the first time. It's far from finished, but you can get a better idea of how it will move and function now.
Step 11: More Floor Extensions and Legs
More regular bricks to form the five parts seen in the first picture.
The second, third, and fourth picture show how to assemble the five parts.
Alignment is critical, so the fifth and sixth picture clarify how to align the new piece with the existing structure.
Pictures seven and eight show the attached piece.
The floor is now large enough to allow the transport swivel plate to swing (and maybe ride) back and forth. You should see basic alignment between the hole in the transport plate and the top of slide. This is where the candy will drop onto the slide.
Step 12: Feeder Tube
Before the sorting begins, candy needs to be fed into the sorter at the correct position. To facilitate this, we construct a feeding tube.
We start with a 4x4 square of plates as seen in the first picture. Notice that one 1x2 piece is intentionally missing on the bottom layer. Candy will be moved away in that direction by the swivel plate. An extra plate could potentially jam larger candy pieces.
A layer of round bricks is built on top of that base, and a second layer is constructed (second picture). Both layers can be joined (third picture).
This tube is one of the only pieces of the structure that will be oriented studs-up. We need a 90-degrees attachment to connect it to the structure that way. The fourth picture shows the components for this construction. Note that we used a 1x2 plate with a sidebar, but ended up not using it. Substitute a regular 1x2 plate if you want. These components form the base of the next layer of the tube, as shown in the fifth picture.
Then a third layer can be added (sixth picture). A couple of plates (three 1x2, two 1x4 and one 1x8) are used to even everything out (seventh picture).
In the final picture, we add a couple of decorational elements, to clearly point out the candy entry point to the user: a couple of 1x2 dial/control plates, an envelope plate and two 1x2 arrow plates on 1x2 pivots. Decoration is optional, even when it is functional...
Step 13: Mounting Wall for Feeder Tube
We need a wall over the raised floor to mount the feeder tube (at 90 degrees). The wall is one unit thick. For alignment with the feeder tube, we insert two plates between the Technic attachments. A third plate is needed to make this wall exactly 9 units high, but that third plate is already mounted on the structure (can you spot a lonely 1x6 blue plate in our pictures?). We used 1x2 bricks with fixed pins, but 1x2 bricks with a hole and a pin are equivalent.
With correct alignment as shown in the second picture, it should now be obvious how the feeder tube attaches to this wall.
Mounting the wall on the sorter is easy. It attaches to the 1x6 plate next to the 16-tooth gear on one side (third picture). We fix it to the raised floor on the other side as well, using a 2x10 brick (fourth picture). You could use a 1x10 brick, as the wall is only one unit thick. We need enough space so the swivelling plate can freely move underneath.
Step 14: Mount the Color Sensor
Another arch extends over the raised floor. It supports the Boost color sensor. Three plates are used to align the sensor as well as possible. One goes on the top side, two on the bottom side. We happened to have a three unit high 2x2 brick, but three separate bricks would be just fine.
The 2x8 brick on the end supports the far end of this arch. We've added a couple of bricks to the raised floor to firmly hold the two arch supports in place (one for the feeder tube and one for the color sensor).
We can now manually swivel the transport plate and check alignment of the transport hole with the feeder tube, the color sensor, and the drop-off point at the top of the slide. You can even test it with a piece of candy (an M&M or Skittle should have the correct size). If the transport plate can not move freely between these three points, you need to retrace your steps, because something went wrong.
Step 15: The Boost Motor
Gather the parts as displayed in the first picture. These include two 24-tooth crown gears and an 8-tooth gear (the smallest Technic gear).
Insert the short red axle into the A motor, and attach the perforated 2x4 plate with the black axle as seen in the second picture. The assembly with the second perforated 2x4 plate holds the black axle in place (third picture).
The stopper prevents the axle from sliding away, but leaves enough space to allow you to manually slide the crown gear away from the 8-tooth gear to stop automatic movement, or to calibrate the starting position before starting the sorter.
Add a leg
Next we'll add a leg to the motor block, to support it at the correct height so the whole structure doesn't topple. Just a couple of regular 8x1 bricks and two plates are enough (picture four and five).
Attach the external cables
Attach both the external motor and the color sensor. It doesn't matter which cable goes where, since the programming blocks don't rely on the connection ID. Picture six and seven show the top view of the motor block and the cables coming from the main structure.
If your Boost block may need new batteries, this is a good time to replace them.
Mount the motor block
We can now mount the motor block. Adjust the crown gears so they grip both the 8-tooth gear on the motor, and the 16-tooth gear on the main structure.
Admire your candy sorter
The sorter is finished! In step 16 we build a base that will hold the sorter and provide four sorting buckets. Then we need to create a Boost program, and the sorter will work! If you want to see the sorter in action as soon as possible, skip step 16 now, and return later if you want.
Step 16: The Base Plate
The first picture shows the 32x32 base plate with all of the parts we use to build the sorting buckets. We foresee spectators on one side, hence we use windows there, so they can see where the sorted candy lands.
The colored translucent pieces on top of that wall are there mainly for decoration, but also they are placed in front of the zone where Skittles of that color will be deposited. The same goes for the translucent blocks in the middle of the base plate.
The side walls are there to hold up the front wall and to avoid spillage. The middle wall is the divider between the green and yellow zone. It features a small 1x2 ridge to avoid Skittles hitting the divider head-on and bouncing back. That's probably an unlikely corner case, but we found the piece so we used it.
The two other dividers can't be placed in standard perpendicular Lego fashion. We worked around that by using 2x2 rotary plates on the base, at a distance of 6x4 of each other, and upright 12x4 plates with 90 degree angle attachments at the last position. Details of the 12x4 plates can be seen the second picture.
The third picture shows the blocks on the right side of the base plate. They are meant to align the legs at the same position every time, so that the pivot point of the slide is centered on the base plate. Pictures five and six provide detailed views. If you built the legs of the structure differently, you should change the position of these blocks to match the legs on your sorter.
Picture six shows the finished base plate as seen from the top.
The final picture shows the sorter as it stands on the base plate.
Step 17: Create the Boost Program
Create a project
The project uses the left internal (A) motor of the Boost block, the external motor and the color sensor. Combining these elements in a program can be done via the “create a project” function of the Lego Boost app. If you've never created your own project, find instructions on the Lego website: https://www.lego.com/en-us/themes/boost/articles/...
Understand what the program needs to do
The main movement is the swiveling candy mover plate, driven by the A motor. Initialize it so the hole aligns with the feeder tube (slide away one of the crown gears to allow free movement, then slide the crown gear in place again). Initialize the slide in the central position.
The program can now, in an eternal loop,
- move the plate “a” steps further using the A motor, “a” being just enough to position the candy below the color sensor. Adapt the “a” constant by experimenting.
- One of the color sensor detection blocks will fire when the candy is in place, setting the “d” variable to the degrees of movement needed from the external motor to swing the slide to the correct zone. In the example, I associate red with -45, yellow with -15, green with 15, and black with 45. You might want to add a detection block for white, setting “d” to 0, to avoid movement when there is no candy.
- The main loop waits for one second, then reads “d” and stores it in variable “c”. Storing the current value of “d” is needed because the color sensor will see bricks of other colors when plate moves. We need to remember the value associated with the candy color so we can move the slide back to the central position.
- The external motor then activates, moving the slide “c” degrees.
- The candy mover plate will now move the plate “b” steps further using the A motor, covering the distance between the color sensor and the drop position above the slide. Adapt the “b” constant by experimenting.
- The program waits one second, which should be enough for the candy to drop in the correct zone.
- The candy mover plate moves back “a” + “b” steps. We specify a negative speed to get the motor to turn in the other direction.
- The slide turns back “c” degrees using the same trick: negative speed with a positive degree value.
Create the program
I think it's fun to write your own program, but to help you, the included picture shows an example program. Values may need to be tweaked for your specific build.
If you tried this project, we'd like to hear from you! Please send us a message at
Bert de Bruijn <email@example.com>.
This instructable and the included pictures are available under the terms of the Creative Commons Attribution-NonCommercial (CC BY-NC) license 4.0 – https://creativecommons.org/licenses/by-nc/4.0/
Tip 4 years ago on Step 14
In a second build, I moved the color sensor one plate thickness to the left in step 14 (towards where the motor block is). Also, in step 9, I used two round 2x2 plates to avoid the slide dropping down instead of the 1x8 plates.
4 years ago
This is really interesting.. Do you happen to have a video to show it in action? I think people would love to see that.
Reply 4 years ago
Thanks for your comment. We rebuilt the sorter to double-check the instructions, and created a short video. Now included at the top of the Instructable! You may notice the color sensor arch is constructed differently in this version. I also moved the sensor one plate thickness to the left. Also, I used two round 2x2 plates to avoid the slide dropping down instead of the 1x8 plates in the instructions.