This NXT Peg Sorter will sort long black NXT pegs from long gray pegs, into two separate bins. A conveyor feeds pegs down in a chute, then the light sensor is used to see the color of the peg as it is sliding down the chute, then a hitting arm hits the black pegs to the side while allowing gray pegs to fall straight down into the other side.
Here is a video of the machine in action:
There are simpler and more reliable ways to sort pegs, but with this project I wanted to do something similar to the way some modern high speed mechanical sorters work in factories. In some of these machines, the items are thrown quickly past a gap in the conveyor belt, where an optical sensor looks for rejects, and then air jets are used to knock the rejected items down through the gap into a reject bin, while the good items continue past the gap to the other side. The challenges are to quickly detect a reject and then to get the right timing between seeing the reject and pushing it out of the fast moving stream. An example is this machine for sorting vegetables (see also the video at the end of the page). Another example that is simpler and closer to how this peg sorter works is seen in this video of a colored pencil sorter.
In this NXT Peg Sorter, the gray pegs are the "good" pegs, and the black ones are the "bad" (e.g. burnt) ones that need to be rejected. The speed of this sorter is limited by how fast the hitting arm can recover after hitting one black peg (not nearly as fast as an air pressure jet can recover), but the rest of the machine is capable of sorting much faster. I didn't put that much time into designing a good hitting arm, so there is definitely room for improvement here. How fast can it get?