Skip to content
PlayOwl
Money, shops & services · #492

How does a vending machine deliver a snack?

A coin checker, a small computer, a turning spiral and a light beam work together to hand you a snack.

The big idea: The machine counts your money. If it is enough, a motor turns a spiral once, and that pushes the front snack off the shelf into the tray.

Start exploring
0 of 5 parts done
A vending machine whose spiral pushes a snack into the tray, How Things Work poster
1Watch it

How a snack gets out

  1. Theo wants the apple chips. They sit behind glass, held inside a metal spiral. No person is inside the machine, so how does it hand over a snack?
  2. Each coin rolls past sensors that measure how big it is and what metal it is made of. That tells the machine its value. The display adds it up.
  3. Theo presses the button for the apple chips. A small computer compares his money with the price. Enough? Then it switches on the motor behind that one spiral.
  4. Look from the side. A motor at the back turns the spiral one full turn. Every snack between the coils slides forward one space, like a nut moving along a screw.
  5. The front snack is pushed off the shelf and falls. On the way down it breaks an invisible beam of light. That tells the machine: the snack really dropped.
  6. Theo lifts the flap and takes his snack. He paid a little too much, so the machine drops his change into the cup. Coin, button, spiral, beam: done!
2Look inside

Look inside a vending machine

The picture on the right shows one shelf from the side. Tap each part to see it work.

  • Coin slot and checker. Coins drop in here and roll past sensors that measure their size and metal, so the machine knows what each coin is worth.
  • Display. The display shows how much money you have put in, and tells you if you need to add more.
  • Selection buttons. Each snack position has a button and a price tag. Pressing a button tells the computer which spiral you chose.
  • Controller. A small computer. It adds up the coins, compares them with the price, and switches on the right motor.
  • Motor. Every spiral has its own small electric motor at the back. It turns the spiral exactly once for each snack sold.
  • Spiral. A wire wound like a spring. Snacks sit between its coils. When it turns, every snack moves forward one space.
  • Drop sensor. A beam of invisible light shines across the space where snacks fall. A falling snack blocks it for a moment, so the machine knows the snack arrived.
  • Delivery bin. The snack lands in this tray. You push the flap inward to reach it.
3Try it

Pay, pick and watch the spiral

Tap pretend coins to pay, then tap a snack. Watch the side view. Try once with too little money and once with enough.

Experiment: You put in less money than a snack costs and press its button. What happens?

  1. Tap one nickel, then tap the pretzels. Read the display.
  2. Add coins until you have enough and tap the pretzels again.
  3. Watch the side view: how far does the spiral turn?

What we found: The computer compares your money with the price before anything moves. Too little money: no motor, and the display asks for more. Enough money: the motor turns the spiral exactly once, which pushes exactly one snack over the edge.

Turn on JavaScript to try it yourself.

4Solve a challenge

Exact change, fewest coins

Serve two customers. Pay the exact price with as few pretend coins as you can, then press the snack they want.

5Go deeper

How a machine sells a snack

A vending machine is a tiny shop with no shopkeeper. It has to do three things by itself: check your money, find the snack you chose, and hand over exactly one.

First, the money. Each coin rolls past sensors that measure its size and what metal it is made of. Every kind of coin is a little different, so the machine can tell a quarter from a dime, and it sends anything strange back out. A small computer adds up your coins and shows the total.

Next, your choice. When you press a button, the computer looks up that snack's price and compares it with your money. If you have enough, it switches on the motor behind that one spiral.

Last, the delivery. The spiral is a wire wound like a spring, with a snack in each gap. The motor turns it once, and every snack moves forward one space, like a nut moving along a screw. The front snack runs out of shelf and falls. On its way down it breaks a beam of light, which tells the computer that the snack really arrived. Then the machine pays your change. The screw comparison is not perfect: a screw moves itself into the wood, but the spiral stays in place and moves the snacks instead.

Key words

Credit
The money you have put in so far that the machine has accepted.
Helix
A spiral shape like a spring or the thread of a screw.
Pitch
The distance from one coil of a spiral to the next. One full turn moves a snack forward by one pitch.
Sensor
A part that notices something, such as a coin's size or a snack falling, and tells the computer.
Controller
The small computer that follows the machine's rules step by step.
Feedback
Checking the result of an action and using it to decide what to do next.

Check your thinking

  1. What moves the snacks toward the front of the shelf?

    Show the answer

    A spiral turned by a motor. The motor turns the spiral, and each turn moves every snack forward one space.

  2. How does the machine tell a quarter from a dime?

    Show the answer

    Sensors measure each coin's size and metal. Each kind of coin has its own size and metal, and the sensors measure both.

  3. You pay too little and press a button. Why does nothing drop?

    Show the answer

    The computer checks the money first and leaves the motor off. No motor turns until the money is at least the price.

  4. What is the beam of light near the tray for?

    Show the answer

    To check that a snack really fell. The falling snack blocks the beam for a moment. No blocked beam means no snack arrived.

  5. A shelf is fitted with a wide-pitch spiral but loaded with thin snack bars. What is likely to go wrong?

    Show the answer

    Two bars can sit in one gap and drop together. One turn empties one gap. If a gap holds two thin items, both are pushed off the edge.