Gummy Bear Automated Detection Without using a MCU
Gummy Bear Automated Detection Without using a MCU
A fully discrete “color computer” that classifies gummy bears (Red/Green/Orange/Clear) by shining five LEDs through the candy, sensing what gets through, and deciding with comparators, shift-register memory, and logic gates.
Gummy bear candy's act like subtractive color filters. I built a small fixture with five LEDs (white, blue, yellow, red, green) on one side and a phototransistor on the other. Each LED is turned on in sequence; the sensor reading is digitized with Schmitt-trigger comparators and the pass/fail bits are stored in 74HC164 shift registers. Simple logic then asserts the output LED for the detected color—no microcontroller required.
What I built. I treated each gummy as a color filter and drafted a pass/absorb table for five LEDs (white, blue, yellow, red, green). The table predicted which LEDs would get through each color (e.g., blue is blocked by red/green/orange but passes clear; red passes red/orange/clear but not green; green passes green/orange/clear but not red).
Why this design. It converts a messy analog problem (spectra, thickness, ambient light) into binary bits per LED—simple, cheap, and explainable.
What happened. The predicted table separated Red/Green/Orange/Clear cleanly. Minor deviations showed up with very dark gummies, but the pattern held once I tuned thresholds.
What I built. An optical path (LED → gummy → phototransistor) feeding an op-amp comparator with positive-feedback hysteresis. I set two thresholds so the output snaps to 1 when light is strong (≈2.0 V) and back to 0 only when it falls well below (≈1.2 V).
Why this design. Hysteresis kills flicker and thickness jitter, giving me a clean digital bit per LED without any microcontroller/ADC.
What happened. With basic tuning of the reference network, the comparator produced rock-solid bits across multiple candies and ambient conditions.
What I built. A clocked LED sequencer that turns on exactly one LED at a time and a 74HC164 shift register chain that stores the comparator bits (so the decision happens after all tests run).
Why this design. One-at-a-time illumination avoids cross-talk and lets me reuse a single sensor. The shift registers give me memory without a microcontroller and keep the wiring minimal.
What happened. The sequence/clock produced repeatable timing. I gated the “result” so outputs only update once the last bit is stored—no “half-made” decisions mid-sequence. Without debouncing I saw multi-step jumps per press; the Schmitt trigger fixed it—one click, one advance—and timing stayed rock-solid across both registers.
What I built. Combinational logic that maps the stored bits to color outputs (red/green/orange/clear). I minimized the equations (De Morgan/NAND-preferred) and used inverters where it saved gates.
Why this design. It keeps the project transparent: you can trace exactly why an LED lights. And it aligns with the goal of a purely discrete “color computer.”
What happened. After one pass of simplification the gate count stayed small and response was instantaneous; I didn’t need any debouncing beyond the comparator hysteresis.
What I built.
I created a quick calibration pass to turn the phototransistor’s analog levels into rock-solid digital bits for each LED. I cycled the LEDs one-by-one with two anchor samples (a clear gummy for “maximum pass” and a dark gummy for “maximum block”), logged the sensor voltage, and set two comparator thresholds per channel: a Vref(high) where the output snaps to 1 and a Vref(low) where it releases back to 0. This forms a hysteresis window so tiny flicker or thickness wobble can’t cause chatter. After setting the resistor ratios for those refs, I re-ran the sweep and trimmed LED currents just enough to keep the window centered.
Why this design.
Real gummies vary (dye, thickness, brand) and ambient light isn’t perfectly stable. Using two spaced thresholds with positive feedback (Schmitt trigger) gives me margin: anything clearly “pass” sits above Vref(high); anything clearly “block” sits below Vref(low); ambiguous mid-levels don’t flip the bit. One shared sensor + one-hot LED sequencing keeps hardware simple and repeatable.
What happened.
With Vref(high) around ~2.0 V and Vref(low) around ~1.2 V (on 5 V supply), each LED produced clean, repeatable bits across all candies tested. Running full sequences on mixed packs, the stored bit-patterns mapped to correct color outputs (Red, Green, Orange, Clear) consistently. Edge cases (very dark Red, extra-pale Orange) still classified correctly thanks to the hysteresis margin; the only tweaks I needed were minor LED-current trims to pull borderline cases away from the window edges.