Project 06 · Build note
Emotion-Detecting Candy Machine
A solo-built machine that taunts you — shuttling your candy around while you're anything but sad — and dispenses it after three sad faces in a row.
I did this project 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 started as a robot that gives people candy when it sees that they’re sad. My professor liked it and said it was a good starting point — but to be a robot it needed a control system. From there I built on it. Scoping up the controls is still my proudest decision on the project.
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.
Machine learning was the other half I’d never touched: I trained the model on over a thousand images of faces. 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, and a good starting point that can be built on.
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. The approach was 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.