LEARN.PARALLAX.COM
Published on LEARN.PARALLAX.COM (https://learn.parallax.com)
Home > Candy Sorter BlocklyProp Project

Candy Sorter BlocklyProp Project

With just two servos, the ColorPal sensor, and a whole lot of hot glue, you can build your own Candy Sorter.   A sturdy cardboard base structure holds the ColorPal Color Sensor above an angled top chute. As you feed individual candies into the sorter, the top servo traps the candy with the ColorPal sensor and it takes a reading.  Then the servo lifts it up and the candy slides down to the bottom chute. The bottom servo turns this chute to the correct cup for that color of candy.

Build the Candy Sorter

Candy Sorter Parts List

  • (1) Propeller Activity Board WX*
  • (1) ColorPAL Color Sensor*
  • (1) 3-pin F-F extension cable*
  • (2) Parallax Standard Servos**
  • (1) 5-cell AA Battery Pack*
  • (5) AA batteries
  • Heavy-duty corrugated cardboard
  • Box knife
  • Hot glue gun & glue, or very strong tape
  • Small bright candies such as Skittles or M&M’s
  • Paper cups

*Items are in the BlocklyProp Starter Kit. ** The BlocklyProp Starter Kit has just one servo, get another servo here.

Propeller I/O Pin Connections

  • P15 ColorPal Sensor
  • P16 – Parallax Standard Servo controlling bottom chute
  • P17 – Parallax Standard Servo lifting sensor in top chute

  • With cardboard, hot glue, and your own ingenuity, build the base structure, with angled top and bottom chutes angled to let the candies slide freely.  The image below is a guide, but there are many possible solutions.
  • Remove the servo horn from the top servo, glue the ColorPAL sensor to it, and then re-attach the horn.  
  • Make sure the jumpers are set to 5V between the servo port pins on the Propeller Activity Board WX.
  • Connect the servos, ColorPAL sensor, and battery pack to the Propeller Activity Board. Then plug the Activity Board into your computer’s USB port.

CAUTION! Don’t try to run this project off of your computer’s USB power alone – use the battery pack too.  The servos can take quite a bit of current when they move, and may exceed the amount of current that your USB port can supply.

 

Program and Tune the Candy Sorter

Build the Candy Sorter Program

  • Go to solo.parallax.com.
  • Either build the program below, or download and open the .svg file.

CandySorterCode.svg

Testing, Tuning, and Adapting to Your Candy

This example program was, through trial and error, tuned to a bag of Skittles and the cardboard structure shown in this tutorial.  You will need to further tune the example code for the individual geometry of your custom candy sorter structure, and the type of candy you are sorting.

  • How do your servo angles look? Run the program, and watch them.
  • At the top of the code loop, adjust the first P17 servo block angle so the ColorPAL can hold a candy in place while it takes a measurement, without smashing it!
  • At the bottom of the code loop, adjust the second P17 servo block angle so the ColorPAL lifts high enough to let a candy roll free again.
  • With the updated code running, start feeding candies into the sorter one at a time, so that each one gets trapped by the ColorPAL and then released. If the ColorPAL is moving too fast or too slow, adjust the pause values at the end of the loop.
  • Once you can reliably feed candies through to be trapped and sensed by the ColorPAL, take a look at where they are ending up.
  • How many different colors does your candy have?  Add an additional else if section if you need more than 5.
  • What colors are your candies? You may need to adjust the color 2 color swatches in each else if condition to most closely match the candies you have. You may have to experiment here. It turns out that brown and orange skittles were hard to tell apart, but changing one condition from brown to dark blue worked well.
  • Where are your candies going?  Put candy collection cups at the endpoints where the rotating chute has been sending the candies as they get sorted.  You may wish to adjust the P16 servo angles in each condition to accomodate the length of your sorter’s chute and the size and position of your collection cups.


Did you know?

Although candy sorting is simply a fun thing to do, material sorting has real-world applications, and can even be used to help protect the environment.  People are more likely to recycle their trash if it’s easy for them to do.  If the garbage facility is able to sort the trash is recieves, it can reduce the amount of trash that ends up in a landfill, and reduce the need to mine for raw materials.  Can think of ways to use machines, sensors, and microcontrollers to sort materials?

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024


Source URL:https://learn.parallax.com/courses/candy-sorter-blocklyprop-project/
Links