The YouTube channel Little Puffin shows how to make this functional mini vending machine.
You might think that a microcontroller would be needed to handle a vending machine’s logic. For one thing, only the correct change should activate them and the wrong change should be returned. If the correct change was detected then a button press should deliver the right food to the dispenser. But if you like puzzles then you might try to think of a way to do with without a microcontroller. After all, the whole circuit can be thought of as a few motors, a power source, and a collection of switches, including the right sized coin.
That’s the way [Little Puffin] approached this donut dispensing vending machine. What’s really fun is to watch the video below and wonder how the logic will all come together as you see each part being put in place. For example, it’s not until near the end that you see how the coin which is a part of the circuit is removed from the circuit for the next purchase (we won’t spoil it for you). Coins which are too small are promptly returned to the customer. To handle coins which are the right size but are too heavy, one enhancement could be to make them fall through a spring-moderated trap door and be returned as well. We’re not sure how to handle coins which are the right size but too light though.