LEGO Boost Candy Sorter

by bertdb in Living > LEGO & K'NEX

9201 Views, 12 Favorites, 0 Comments

LEGO Boost Candy Sorter

IMG_6769 crop.JPG
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:

  1. the swivelling plate picks up one candy by moving the hole under the feeder tube
  2. It turns to move that candy under the color sensor.
  3. The color sensor sees the color, and a slide rotates so that the candy will fall in the correct color zone or bucket.
  4. The plate turns to bring the candy to the drop location, where the floor ends and the slide begins.
  5. 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.

Swivelling Transport Plate

12_IMG_6875.JPG
12_IMG_6874.JPG

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.

Technic Gear Assembly

12_IMG_6873.JPG
12_IMG_6872.JPG
12_IMG_6871.JPG
12_IMG_6870.JPG

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.

Prepare the Connection to the Motor Block

12_IMG_6869.JPG
12_IMG_6868.JPG
12_IMG_6867.JPG
12_IMG_6866.JPG

Get parts

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.

Assemble

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.

Decoration

12_IMG_6865.JPG
6_IMG_6863.JPG

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!

Build the Raised Structure

6_IMG_6862.JPG
6_IMG_6861.JPG
6_IMG_6859.JPG

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.

Add a Second Leg

6_IMG_6856.JPG
6_IMG_6855.JPG

Build

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

Attach the second leg as shown in the second picture.

Extend the Floor

6_IMG_6854.JPG
6_IMG_6852.JPG

Build

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.

Attach

The second picture shows where to attach the floor extension.

Build the Rotating Mechanisme for the Slide

6_IMG_6851.JPG
6_IMG_6850.JPG
6_IMG_6849.JPG
6_IMG_6847.JPG

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.

Build the Slide

6_IMG_6845.JPG
6_IMG_6844.JPG
6_IMG_6843.JPG
6_IMG_6841.JPG
6_IMG_6839.JPG
6_IMG_6838.JPG
6_IMG_6837.JPG

Build

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.

Attach

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.

Add Another Leg and More Floor Space

6_IMG_6835.JPG
6_IMG_6834.JPG
6_IMG_6833.JPG
6_IMG_6832.JPG
6_IMG_6829.JPG

Build

The next leg is built from standard Lego bricks. No Technic elements, no plates, no narrow beams, just bricks.

Attach

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.

More Floor Extensions and Legs

6_IMG_6827.JPG
6_IMG_6826.JPG
6_IMG_6825.JPG
6_IMG_6822.JPG
6_IMG_6821.JPG
6_IMG_6820.JPG
6_IMG_6819.JPG
6_IMG_6818.JPG

Build

More regular bricks to form the five parts seen in the first picture.

Assemble

The second, third, and fourth picture show how to assemble the five parts.

Attach

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.

Check

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.

Feeder Tube

6_IMG_6816.JPG
6_IMG_6813.JPG
6_IMG_6812.JPG
6_IMG_6811.JPG
6_IMG_6810.JPG
6_IMG_6808.JPG
6_IMG_6806.JPG
6_IMG_6804.JPG

Before the sorting begins, candy needs to be fed into the sorter at the correct position. To facilitate this, we construct a feeding tube.

Build

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).

Decorate

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...

Mounting Wall for Feeder Tube

6_IMG_6803.JPG
6_IMG_6801.JPG
6_IMG_6796.JPG
6_IMG_6794.JPG

Build

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.

Assemble

With correct alignment as shown in the second picture, it should now be obvious how the feeder tube attaches to this wall.

Mount

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.

Mount the Color Sensor

6_IMG_6791.JPG
6_IMG_6788.JPG
6_IMG_6787.JPG

Build

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.

Attach

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).

Check alignment

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.

The Boost Motor

6_IMG_6786.JPG
6_IMG_6784.JPG
6_IMG_6783.JPG
6_IMG_6782.JPG
6_IMG_6781.JPG
6_IMG_6779.JPG
6_IMG_6780.JPG
6_IMG_6773.JPG
6_IMG_6772.JPG
6_IMG_6769.JPG

Build

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).

Assemble

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.

Replace batteries

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.

The Base Plate

6_IMG_6768.JPG
6_IMG_6766.JPG
6_IMG_6764.JPG
6_IMG_6774.JPG
6_IMG_6775.JPG
6_IMG_6763.JPG
6_IMG_6778.JPG

Build

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.

Admire

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.

Create the Boost Program

boost-snoepsorteerder-programma-screenshot.png

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,

  1. 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.
  2. 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.
  3. 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.
  4. The external motor then activates, moving the slide “c” degrees.
  5. 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.
  6. The program waits one second, which should be enough for the candy to drop in the correct zone.
  7. The candy mover plate moves back “a” + “b” steps. We specify a negative speed to get the motor to turn in the other direction.
  8. 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.

Have fun!

If you tried this project, we'd like to hear from you! Please send us a message at

Bert de Bruijn <legoboostcandysorter@debruijn.be>.

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/