🎒 What you need
- your servo or motor rig from module 7, mounted
- a chute or ramp, two tins, and material to sort: maize grains, beans, bottle caps
- the shared phone for code and one photo or short video
✋ Do this
- Draw the state machine FIRST, on paper, the way you learned in module 2: WAITING, DECIDING, SORTING LEFT, SORTING RIGHT, back to WAITING.
- Build the physical path: a chute that delivers one item at a time to the arm's reach. Getting one item at a time is harder than the code and you should expect to redesign it twice.
- Write the control code as one loop with a function per state. Keep each function short enough to read on a phone screen without scrolling.
- For version one, you are the sensor: press a key for good or bad and let the arm act. Separating deciding from acting is a design choice, not a shortcut.
- Run 30 items. Record: how many were correctly placed, how many jammed, and the total time. Three honest numbers.
- Fix the single biggest failure, run 30 again, and put the two result sets side by side. Then photograph the rig with your state diagram and code beside it, and explain the whole thing to someone in under two minutes.
💡 Why it works
You have now built a complete cyber-physical system: a state machine, a control loop, an actuator, a mechanical feed and a measured evaluation. Industrial grain and coffee sorters differ from yours in speed and in having a camera where you stood, but the architecture on the whiteboard is the same one you drew on paper. Jams, incidentally, are where real sorting machines actually spend their engineering budget.
🔥 Challenge
Replace yourself as the sensor. Use the phone camera and your classifier work, or a simple light sensor, so the machine decides for itself. Then measure how much worse it is than you — and be honest about the number.
📖 New words
Tap when you have finished this module.