Project 06 · Build note

Emotion-Detecting Candy Machine

Get candy only by looking sad three times in a row: a solo-built machine that classifies faces at 65% and taunts everything else.

Context
BU ME 416 (Introduction to Robotics)
Date
Fall 2024
Team
1 person
Duration
~1.5-month assignment, ~3 weeks active build
My scope
Sole designer and builder · Mechanical design and 3D printing · Controls (steppers + drivers) · ML emotion detection
Status
Dismantled for parts and scrap PLA
Emotion-detection accuracy
65%
measured on a controlled 100-image test set — better than the coin flip a useless classifier would score
Build time
~3 weeks active
inside a ~1.5-month assignment — solo and from a blank page, I owned every part of it
Budget
$0 — school-lab 3D printing
the Lego conveyor was the only part I bought
Actuation
2 NEMA 17 steppers
my first steppers — and one's torque became the failure I never fixed
Watch the loop close: anything short of three sad faces in a row gets the candy shuttled back and forth behind the acrylic; three in a row gets it dispensed.

I did this one entirely on my own for ME 416, BU’s Introduction to Robotics — I owned every part of it, and it started from a blank page. No budget at all — just what I could make at the school robotics lab; the assignment ran about a month and a half, and my actual working time on it was around three weeks. The idea: a robot that gives people candy when it sees that they’re sad.

My professor liked it — a good starting point, but not a robot, since there was no control system. I said okay: I can build on this.

Scoping up the controls is still my proudest decision on it.

The detection pipeline

It’s a hopper up top, a valve underneath, and a Lego conveyor under that — the Lego was the only bought part, everything else 3D printed in PLA, with a laser-cut acrylic window so you can watch your candy move. The whole loop ran in MATLAB on my laptop: the laptop camera takes your picture, a model I found online and trained on faces calls it happy or sad, and MATLAB drives an Arduino to move the motors. The rule is strict — three sadness detections in a row and the candy is yours; anything else and it taunts you. Taunting means the valve rocking about 30° either side of vertical — tip too far one way and the candy drops — while the conveyor shuttles it back and forth behind the acrylic; on the third sad face the valve rotates 180° and the conveyor runs forward to dispense. Two NEMA 17 steppers and their drivers do the moving; they took me the longest — I had little experience with them before.

The other half of the machine: a model I found online and trained on faces, running in MATLAB, calling faces happy or sad in real time.

Machine learning was the other half I’d never touched: on a controlled set of 100 test images the happy/sad calls landed at 65% — better than the coin flip a completely useless classifier would score, but not nearly the success I hoped for.

The conveyor that stayed slow

I had listed failure points up front: the valve not turning, the valve not holding candy, the conveyor interface not connecting, the motor torque needing improvement. It was very much design it, print it, fail fast — roughly four valve versions and two conveyor housings by the end. The failure that landed was one I did not expect and ultimately was not able to fix: the conveyor belt never turned fast enough, a result of the stepper motor’s torque, and the machine demoed with the slow conveyor. The demo still ran end to end — I stood in front of the camera happy and got taunted, then held up a controlled sad-face picture and the candy properly went through the machine. Starting over I’d change the conveyor drive and the detection algorithm — with everything I know now, I believe I could build a vastly improved version in about half the time.

The machine