Candy color sorter
A candy color sorter: a feed disc carries each candy under a TCS34725, then drops it on a servo chute that sends it to one of six bins.
Read each candy's color and swing the chute to its bin before it drops: the hopper feeds one every two seconds.
Pins
| Pin | What it does |
|---|---|
VCC, GND |
5 V for the sensor board, the chute servo and the feed motor. |
SCL, SDA |
The TCS34725's I2C bus, at address 0x29. |
SERVO |
The chute servo's signal. |
The sensor and the servo are the parts a home build uses, on the pins they have on the bench, so a sketch written for the loose parts runs the sorter unchanged.
How it works
The feed disc turns on its own little gear motor whenever VCC has 4 V or
more: one pocket every two seconds (period), the first a second after
power-up. Each pocket brings the next candy from the hopper under the sensor
and holds it there for 1.4 seconds, then drops it through a hole onto the
chute. Between candies the sensor sees the dark disc, which a sketch should
read as an empty chute. When the hopper is empty the disc stops.
The hopper starts with candies (12) in a fixed order: red, yellow, blue,
green, orange, purple, then blue, red, green, yellow, purple, orange. The
round arrow fills it again and empties the bins.
The chute is on an SG90. A candy slides off its end a third of a second after it drops, into whichever bin the chute points at by then. The six bins are 30 degrees each, bin 1 from 0 to 30 degrees and bin 6 from 150 to 180, so 15, 45 and so on up to 165 are their middles.
What the model gets right
- The sensor is the TCS34725 model, registers, gain, integration and counts, looking at the candy lit by the board's LED.
- The chute is the servo model: the Arduino library's pulse window, 600 degrees a second and no motion under 4 V.
- Everything is deterministic: the same sketch sorts the same candies into the same bins.
What it does not model
- Candies jamming, two in one pocket, and light from the room.
- The feed motor's own load on the supply.