Harness the colors of the rainbow with the Skittle Pixel8r. Learn how to construct a machine that will create any image using Skittles as pixels. The machine is capable of creating a Skittle pixel image that is up to 785x610mm (31x24in) using eight Skittle colors (hence the name Pixel-"8"-r).
Eight Skittle dispensers (one for each color of Skittle) are placed at the top of the machine. The Arduino commands the dispenser containing the desired color to dispense one Skittle. Once dispensed the Arduino commands the linear axis to move the funnel to the correct bin. While the linear axis is moving, the Skittle falls through the funnel system. After the linear axis stops moving, the Skittle falls into the bin. This process repeats 2760 times until the image is complete.
It was supposed to be a weekend project but ended up taking a month to design and build. Skittles are surprising challenging to work with: they can roll on all sides but are not spheres, when dropped they naturally settle with the larger diameter in the horizontal plane, and the raspberry ones are irresistibly tasty.
I have uploaded a .step solid model file of the machine (see attached file). When I don't provide good descriptions of dimensions and assembly, open this .step file in your favorite 3D CAD program to find the information you need.
- Table saw (1/8" wide blade)
- Jig saw
- Miter saw
- Hack saw
- Laser cutter with at least 400x300mm (16x12in) bed size
- Electric drill
- Drill bit set
- Wire cutter
- Wire stripper
- Small Phillips screw driver
- Soldering iron
- Utility knife
- Tape measure
- Qty 1 – Arduino Mega 2560
- Qty 1 – 5V power supply
- Qty 1 – 12V power supply (to power stepper motor and Arduino Mega 2560)
- Qty 9 – microswitches
- Qty 8 – 180 degree, metal gear, 5VDC servo motors
- Qty 1 – Nema 17 stepper motor (64 oz-in or greater)
- Qty 1 – microstep stepper motor driver
- Qty 1 – 85x54x9mm bread board
- Qty 1 – Dupont wire 2.54mm pitch connector kit (male crimp pins, 1x1 pin female housing, 1x2 pin female housing, etc.)
- Qty 1 – USB type B to USB type A cable (to connect Arduino Mega 2560 to computer)
- Qty 1 – 22 AWG, 4 conductor, ribbon cable, 20m
- Qty 200 – 4” cable tie
- Qty 1 – 4oz. bottle of wood glue
- Qty 8 – ¼-20 hex head bolt, 0.75in long
- Qty 8 – ¼-20 hex nut
- Qty 8 – lock washer for ¼-20 bolt
- Qty 10 – 1.5in long wood screw
- Qty 20 – 2.5in long wood screw
- Qty 2 – M5x30mm bolt
- Qty 6 – M5 hex nut
- Qty 6 – M5 lock washer
- Qty 2 – M5 threaded rod, 100mm long
- Qty 4 – M4x18mm bolt
- Qty 8 – M4 hex nut
- Qty 4 – M4 lock washer
- Qty 4 – M3x8mm bolt
- Qty 1 – M3x16mm bolt
- Qty 1 – M3 hex nut
- Qty 5 – M3 lock washer
- Qty 8 – 16x12x0.175in Baltic birch plywood
- Qty 47–0.75x24x0.175in Baltic birch plywood
- Qty 1 – 15x39x0.75in plywood
- Qty 1 – 24x36x0.75in plywood
- Qty 3 – 2x4in lumber, 96in long
- Qty 1 – 24x36x0.175in glass sheet
- Qty 1 – 1.5x48x0.175 aluminum plate
- Qty 1 – large equipment funnel
- Qty 1 – medium automotive funnel
- Qty 2 – small automotive funnel
- Qty 1 – 0.75in OD, 0.625 ID, vinyl tubing, 3ft long
- Qty 4 – 4x13x6mm v-bearing, 4mm ID
- Qty 1 – 3m of GT2 timing belt, 6mm width
- Qty 1 – 20 tooth, GT2 timing belt pulley, 5mm bore
- Qty 1 – 20 tooth, GT2 timing belt idler pullley, 3mm bore
- Qty 2 – grey spray paint, 12oz can
- Qty 8 – medium size sealable containers (one for each skittle color)
- Qty 2760 – Skittles (estimate 25 skittles and equal number of colors per ounce)
- Qty 1 pkg – 1/8" heat shrink
- Qty 1 pkg – solder for electronics
Step 1: Construct the Skittle Dispensers
The most difficult challenge of this project was designing a cheap device that can dispense Skittles one-by-one from a pile of Skittles. After a couple of iterations I settled on the following design that can be laser cut from 1/8” Baltic birch plywood and operated using a 180 degree, metal gear servo and limit switch. It is important that a metal gear servo be used; the gears of a plastic gear servo are likely to strip for this application. One dispenser is required for each Skittle color. Laser cut the .dxf file (formatted in millimeters) out of a 16x12x0.175in sheet of Baltic birch plywood. Quantity of 8 are needed. Twelve zip ties are required to assemble each dispenser. Use the screws supplied with the servo to fasten the circular plates to the servo horn. Solder 900mm of 2 conductor, 22 AWG wire to the Common and NO (normally open) terminals of the micro-switch. Terminate the other end of the 22 AWG wires with 1x1 pin male Dupont connectors. Use the attached "servo_zero.ino" arduino script to orient the horn/hole plate on the servo at the correct position (see images for details). The .gif shows the correct disk travel when the servo sweeps from position 0 to position 180.
Follow the assembly sequence shown in the pictures.
Step 2: Construct and Assemble the Frame
- Cut a 6in diameter hole in the middle of the 15x39x0.75in plywood using a jig saw.
- Cut the two 2x4x 96in boards to 72in long using a miter saw.
- Fasten the two 2x4x96in boards to the 15x39x0.75in plywood using 2.5in wood screws. The 2x4x96in boards whould be centered on and flush with the sides of the plywood (see image of assembly).
- Use the remaining two 24in long pieces of the 2x4in boards for the feet. Fasten the feet to the legs using the 2.5in wood screws (see image of assembly).
Step 3: Construct the Linear Axis
The linear axis moves the funnel system to each Skittle bin of the bin plate.
- Laser cut the .dxf file (formatted in millimeters) out of a 16x12x0.175in sheet of Baltic birch plywood.
- Drill 2 holes 3.75in from one side of the 1.5x48x0.175in aluminum plate. Dimensional details included in the images.
- Drill 2 holes 6.75in from other side of the 1.5x48x0.175in aluminum plate. Dimensional details included in the images.
- Follow the assembly instructions included in the images.
Step 4: Construct and Install the Skittle Bin Plate
The goal of the skittle bin plate is to create 46 0.5625x0.5625x24in vertical bins that are visible from one side. We attempted several methods including vinyl tubing and v-grooves in plywood before arriving at the bin plate design that is discussed here.
- Cut 47 grooves, 0.5625in apart, 0.375in deep into one face the 36x24x0.75in sheet of plywood using a 1/8" table saw blade. Center the grooves in the 36in width of the plywood. See images for additional dimensional details.
- Insert 47 24x0.75x0.175in Baltic birch slats into each groove of the plywood. Make sure they are flush with the top and bottom of the bin plate. Wood glue them into place if desired.
- Cut two 1.5x1.75(approx)x24in from a 24in long 2x4 board with the table saw.
- Secure 1.5x1.75x24in boards to the vertical sides of the back of the bin plate using 2.5in wood screws. These help straight out the plywood board and are used to mount the Skittle bin plate to the frame.
- Spray paint the front of the bin plate gray.
- Secure the bin plate to the frame through the 1.5x1.75x24in boards. Top of the bin plate should be 31.5in from the bottom of the frame. When the 24x36in glass is installed on the front, there should be a 0.5in between the front of the 2x4 frame and the front of the glass.
Step 5: Construct and Install the Skittle Funnel
The Skittle funnel guides the Skittles from the dispensers to the bin plate. It consists of four store bought funnels and a 29in length of 0.75in OD, 0.625in ID vinyl tubing. It took a couple hours of playing around to figure out a configuration of funnels that would work. The main challenge is preventing the vinyl tubing from kinking and causing a Skittle to get stuck. Seems like there is still room for improvement here. The assembly instructions are detailed in the images. Ensure that all funnel inside diameters are at least 0.6in to allow the Skittles to pass easy.
Step 6: Wire the Electrical Components
Wire the bread board, servos, stepper motor, stepper motor driver, and switches per the wiring diagram image. Connect servo power to the breadboard. Connect one lead of each terminal strip to breadboard ground. Connect the 5V power to the bread board and the 12V power to the Arduino Mega and stepper motor driver. Pay special attention to any grounding connections.
Arduino Mega pin assignments:
- Dispenser 0 servo, signal pin -> D23
- Dispenser 1 servo, signal pin -> D25
- Dispenser 2 servo, signal pin -> D27
- Dispenser 3 servo, signal pin -> D29
- Dispenser 4 servo, signal pin -> D31
- Dispenser 5 servo, signal pin -> D33
- Dispenser 6 servo, signal pin -> D35
- Dispenser 7 servo, signal pin -> D37
- Dispenser 0 switch -> D22
- Dispenser 1 switch -> D24
- Dispenser 2 switch -> D26
- Dispenser 3 switch -> D28
- Dispenser 4 switch -> D30
- Dispenser 5 switch -> D32
- Dispenser 6 switch -> D34
- Dispenser 7 switch -> D36
- Linear axis limit switch -> D2
- Stepper motor driver, step -> D8
- Stepper motor driver, direction -> D9
- Stepper motor driver, enable -> D10
- 12VDC power supply, positive -> Vin
- 12VDC power supply, negative -> Gnd
- Breadboard ground -> Gnd
Step 7: Create a Rainbow Spiral Using GIMP
- Download and install GIMP - Gimp Download Page
- Run GIMP and create a new blank canvas image (File->New, 640x400 size recommended)
- Select the gradient tool from the Toolbox window
- In the tool options of the gradient tool select: "Full saturation spectrum CW" for the Gradient and "Spiral (cw)" for the Shape.
- Click and drag from the center to the edge of the canvas to create the spiral (play around with it to get the type of spiral you want)
Step 8: Convert Image to Skittle Pixels Using GIMP
- Download and install GIMP- GIMP Download Page
- Open image you want to convert to skittle pixels in GIMP
- Create a new palette of skittle colors (go to Windows->Dockable Dialogs->Palettes). I determined the following rgb skittle palette colors by using the color picker tool: red (255, 2, 19), orange (255, 79, 0), yellow (255, 218, 0), green (3, 255, 13), blue (0, 232, 255), indigo (1, 43, 255), violet (255, 0, 225).
- Size the image to resolution of the skittle machine (Image -> Scale Image). Input 46 pixel wide, 60 pixel height for bin size of this machine. After scaling the image, it will look out of proportion but that is intentional. This is because when Skittles are placed in the bins they are wider than they are tall (i.e. rectangular pixels), but pixels in the GIMP program are square. After scaling, think of the image as a map of what color of skittle needs to go where rather than what the final image will look like.
- Convert the image to the Skittle palette colors (Image -> Mode -> Indexed -> choose the Skittle color palette that you created)
- Convert the image to rgb (Image -> Mode -> RGB)
- Save the image as a .png image file
Step 9: Extract Skittle Pixel Information Using Python
During this step you will extract the Skittle pixel information from the image. This Python script will output a list of Skittle colors that you will eventually copy over to the Arduino code and provide a count of how many of each color of Skittle is required to create the image.
- Download and install Python and your favorite Python IDE (If you are unfamiliar with this process, do a quick internet search. I use the Anaconda Python package and the Syder IDE that comes with it.)
- Change the "image_filepath" variable of the python get_skittle_pixel_data.py script (see attached) to match the file path of the image you are extracting the pixel information from (i.e. the Skittle pixel image from the last step).
- If you didn't use the same GIMP palette that I did, update the "skittle_color" and "skittle_color_rgb" lists of the python script to match the color names and rgb values used in your GIMP Skittle palette. The order in which the colors are listed in the "skittle_color" and "skittle_color_rgb" lists have a downstream consequence that is important to note now but may not make sense until you review the Arduino code - the position of each color in these lists corresponds directly to Arduino microcontroller pin order of Skittle dispenser. For example, if the zeroth position of the "skittle_color" and "skittle_color_rgb" lists is "red" and "(255,2,19)" respectively, then you will load red Skittles into the Skittle dispenser hooked up to the lowest dispenser pin numbers on the microcontroller.
- Run the get_skittle_pixel_data.py script. The python console should output a large list of integers and at the bottom of that list should be the quantity of each Skittle color required.
- The first time I extracted the Skittle pixel information from the image, I learned that the rainbow spiral image would cost 740 green Skittles. The next highest was 520 blue. Instead of buying enough Skittle bags to get 740 green, I just reduced the number of green pixels in the image to less than 500. The modified rainbow spiral image is attached.
- Make sure you have access to the outputs from the Python script for the next couple of project steps.
Step 10: Program the Arduino
This step details how to program the Arduino microcontroller with the instructions it uses to create your image using Skittles.
- Download and install the Arduino IDE - Arduino Software Download Page
- Open the attached skittle_pixel8r.ino (attached) in the Arduino IDE
- Copy the integer list that was generated from the previous project step with the python script to the "skittle_color" array of the skittle_pixel8r.ino file.
- Update the "num_skittle_pixel" integer variable with the number of Skittle pixels in the copied array. This is the same as the number of pixels in the resized image. For this machine it is 46 width x 60 height = 2760 skittle pixels.
- Connect the Arduino Mega microcontroller to your computer using the USB and upload the skittle_pixel8r.ino script to the microcontroller using the Arduino IDE.
See comments in the Arduino code for functional details.
Step 11: Sort Skittles by Color
- The output of the python script lists how many Skittles of each color is needed to construct your image. The rainbow spiral image I am using as an example for this Instructable requires the following of each Skittle color: 321 red, 334 orange, 440 yellow, 443 green, 397 blue, 457 indigo, 368 violet
- When you are buying the Skittles, estimate about 25 Skittles per ounce and equal number of each color per ounce. Traditional Skittles are red, orange, yellow, green, and violet. Additional colors like blue, indigo, and white are available as part of other Skittle flavor packs.
- Put on a good movie or television show.
- Manually sort your Skittles by color into each sealable food container. Feeling ambitious? - make one of the many automated Skittle color sorter designs that are posted online.
Step 12: Create an Image With Skittles
- Provide power to the Arduino and plug in the 5V and 12V power supplies.
- The linear axis homes to the limit switch.
- The linear axis moves to the farthest right Skittle bin.
- A Skittle is dispensed.
- The linear axis moves the funnel leftward to the next Skittle bin.
- A Skittle is dispensed. The Arduino serial monitor displays the bin number and skittle_color array position that corresponds the Skittle that was just dispensed.
- Once the farthest left bin is reached, the linear axis homes to the limit switch again and moves to the farthest right bin.
- This process repeats until the entire image has been created. It took approximately two and a half hours to complete the rainbow spiral image with 2760 Skittles.
- Congrats, you made it this far and that is no small feat. If you have suggestions on how to improve this project please post in the comments.
Runner Up in the
Colors of the Rainbow Contest