Gumball machines are pretty impressive, especially when you consider that there is no embedded microprocessor inside running the show. In this video, animator Jared Owen does a wonderful job showing how the various mechanisms in a gum machine work to reliably trade you gumball for a coin.
Image: YouTube screenshot