How I got my color sorting machine running right - tips I wish I'd had at the start

Oct 31, 2026 Last reply: 8 hours ago 5 Replies

First reply

russ.vance

I ran into the same drifting readings problem with mine, but instead of a calibration at boot I take three readings per candy and throw out the first one. The sensor needs a beat to adjust after the piece lands under the light, and that first sample was garbage on mine maybe…

Read the full reply

Built one of these last year and the biggest thing I learned is that consistent lighting matters more than the sensor itself. If ambient light changes during the day, your readings drift and colors get misread. Stick a small fixed light source over the sensing spot and shield it, then run a calibration routine at startup like the LCD setups do. Takes ten seconds each boot and saves hours of head scratching. Feeding is the other trap. Candies tumble and jam in the hopper if the angle is too shallow, so keep the chute steep and let gravity do the work. I also learned to pulse the motors briefly instead of running them continuously, which keeps pieces from riding along on top of each other. One more thing, test your tube drop timing with a piece of paper taped over the collection cups before you trust it. Mine was releasing two candies per cycle for weeks because the gate closed a beat too slow. Slow the sequence down, confirm one piece per drop, then speed it back up gradually.


I ran into the same drifting readings problem with mine, but instead of a calibration at boot I take three readings per candy and throw out the first one. The sensor needs a beat to adjust after the piece lands under the light, and that first sample was garbage on mine maybe one in five times. Two clean readings agreeing is what I trust. I put a strip of black craft foam around my LED so light only hits the sensor spot from above, wich helped way more than I expected.

For jams, I gave up on the chute entirely and used a little rotating drum with pockets, kind of like a gumball dispenser. Each pocket holds exactly one piece so the count is built in. It was fiddly to get the pocket depth right with M&Ms since they lie flat or stand on edge, but once I sanded the edges of the pockets smooth the misfeeds basicly stopped. One thing I'd add to the timing issue: my servo gate kept slowing down as the day went on because the servo horn screw worked loose. Check the mechanical side before blaming the code. A drop of threadlocker fixed it for good.

Not sure the drum idea generalizes though. Skittles are round, so mine just rolled right out of shallow pockets no matter how I tuned the depth. I got better results from a vibrating rail, basically a small plate on an eccentric weight that feeds one piece at a time down a single-file lane. Slower, but it never double-feeds and nothing jams. Did you find the drum worked with spheres at all, or were you only ever sorting flat candies with it?

Mounting this whole thing on the Skadis board itself taught me a lesson the hard way: the feeder motor vibration travels straight thru the panel and onto the sensing spot, so my color readings wobbled even with a shielded light. I ended up putting the electronics on a seperate bracket that never touches the pegboard and my error rate dropped to almost nothing overnight. Also worth checking your wiring if you're running several servos off the Arduino's own 5V pin, that browned mine out on every simultaneous move til I gave the servos thier own 5V 2A supply.

What finally fixed my flickering readings was lining the little pocket where the candy sits with dark felt. I had candies bouncing slightly when they dropped in, and even a tiny bounce threw off the color match every time. Felt kills the bounce and kills glare at the same. I glued a scrap of it from an old drawer liner and never touched the code after that. Also noticed older Skittles with scuffed shells read darker, so if my sort rate drifts after a refill I just re-shoot my reference values and it settles down.

Update: finally got this running solid. The felt trick worked wonders. I lined the sensing pocket with some dark felt and the bounce and glare problems both vanished. I also kept the discard-the-first-reading idea and it cleaned up my matches almost completely. Ran a few hundred pieces through last night with zero miscounts. Chute is steep enough now that jams are rare too.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required