Desktop color-sorting robot for candy and beads
A printed hopper feeds one piece at a time past a TCS34725 color sensor, then a second SG90 servo swings a chute to drop it into the right cup. An Arduino UNO runs it, and an AI helper writes and tunes the color thresholds.

Safety first
- Small round candy and beads are choking hazards for young children. Supervise kids and keep the sorted pieces away from toddlers.
- Printed PLA parts are not certified food-safe. Treat candy that went through the machine as a toy, not food, or sort beads instead.
- Power the servos from the 5 V adapter rail, not the UNO 5V pin, to avoid brownouts.
Parts
| Part | Qty | Approx. each | Subtotal |
|---|---|---|---|
| ELEGOO UNO R3 board with USB cableCatalog ASIN. Typical $14-22.Amazon | 1 | $17 | $17 |
| TCS34725 RGB color sensor moduleHas its own white LED, which you can switch from a pin. Typical $6-12, no verified link.Amazon (search) | 1 | $8 | $8 |
| SG90 9 g micro servo (Beffkkip 5-pack)Uses 2: one turns the feeder disk, one aims the chute. Price seen $9.88 for a 5-pack in our parts catalog (Nov 12, 2026). Typical $8-14.Amazon | 1 | $9.88 | $9.88 |
| 40-pin 20 cm female-to-female jumper wiresCatalog ASIN. Typical $4-8.Amazon | 1 | $5.50 | $5.50 |
| 5 V 2 A USB wall adapterFeeds the separate servo rail (see Wiring); the UNO itself runs from USB. Typical $5-10, no verified link.Amazon (search) | 1 | $7 | $7 |
| USB to 5.5x2.1 mm barrel cable plus screw-terminal adapterTypical $4-8, no verified link.Amazon (search) | 1 | $6 | $6 |
| Silicone baking cups (set)Six cups for six colors. Typical $4-9, no verified link.Amazon (search) | 1 | $6 | $6 |
| Estimated total (parts only) | $59.38 | ||
Typical US prices, checked 2026-11-12. Prices change and multi-packs are often cheaper per piece.
As an Amazon Associate I earn from qualifying purchases. Prices change; check the store.
Filament
PLA (1.75 mm): about 250 g (83.9 m), roughly 14 h of printing.
PLA, 0.2 mm layers, 15% infill, 2 walls. Print the feeder disk flat; sand its pocket smooth so pieces do not stick.
AI agents you'll use
- Code helper (ChatGPT, Claude, Gemini or Grok): Writes the UNO sketch: feed, read, classify, aim chute, drop. Helps you turn logged RGB readings into thresholds.
- Calibration helper: Takes the readings you log for each color and suggests a nearest-color classifier instead of hand-tuned ifs.
Tools
- Small Phillips screwdriver
- Hot glue gun
- USB data cable
- Optional soldering iron for header pins
What you'll learn
- Reading an RGB color sensor
- Calibrating color thresholds from real samples
- Sequencing two servos
- Simple state machines
Pour a mixed handful in the top and watch it sort itself into six cups. It is a great first robot because every step is visible: feed, look, decide, drop.
What you'll build
A desk machine about 20 cm tall. A slotted disk under the hopper carries one piece to the TCS34725 sensor, the UNO classifies the color, the chute servo swings to one of six positions, and the disk drops the piece down the chute.
The cost range is $50-70 for the parts listed below, allowing about 10% either way for price swings.
Print the parts
Search Printables or Thingiverse for an SG90 "color sorter" (the TCS34725 Skittles-style sorter is a common design), check the license and credit the designer. Pieces must fit the feeder pocket; check that before printing everything.
Wiring
| From | To | Notes |
|---|---|---|
| TCS34725 VIN / GND | UNO 5V / GND | Most modules have an onboard regulator; check yours. |
| TCS34725 SDA / SCL | UNO A4 / A5 | I2C. |
| TCS34725 LED | UNO D4 | Optional, to turn the white LED on only while reading. |
| Feeder servo signal | UNO D9 | |
| Chute servo signal | UNO D10 | |
| Servo red wires | 5 V adapter + | Separate servo rail. |
| Servo brown wires and adapter - | UNO GND | Common ground is required. |
Step-by-step
- Print the parts and test that one piece fits the feeder pocket.
- Wire the sensor and run an example sketch from the library; confirm readings change with color.
- Wire both servos to the separate 5 V rail and center them.
- Log 10 readings for each color with the LED on, in the final enclosure (ambient light matters).
- Ask the AI helper to turn those logs into a nearest-color classifier.
- Map six chute angles to six cups and test each by hand.
- Run the full loop slowly, then speed it up until errors appear and back off a little.
Code
Arduino IDE with the Adafruit TCS34725 and Servo libraries.
Prompt for the code helper:
Write an Arduino UNO sketch for a color sorter: TCS34725 on I2C with its LED on D4, feeder servo on D9, chute servo on D10.
Loop: rotate feeder to the sensor, settle 200 ms, take 3 readings and average, classify by nearest stored RGB centroid (I will paste my logged values), move chute to that color's angle, rotate feeder to drop, repeat.
Add an "unknown" bin if the distance to every centroid is too large, and print readings to Serial.
Troubleshooting
- Two colors get mixed: Readings overlap. Shield the sensor from room light and re-log both colors.
- Pieces jam in the feeder: The pocket is too tight or rough. Sand it or scale the disk slightly.
- UNO resets when servos move: Servos are on the UNO 5V pin. Move them to the separate adapter rail.
Files, code and docs
- Adafruit TCS34725 library (BSD)
- Arduino Servo library (LGPL-2.1)
Last checked 2026-11-12. Double-check parts against your own board and seller listings before you buy.