The surprising science behind Japan’s vending machine obsession

Japan is synonymous with vending machines. The island-nation has vending machines for everything: fresh flowers, bowls of hot ramen, edible grasshoppers, umbrellas. Want a fresh farm egg or flower bouquet? There’s a vending machine for that! 

Japan is home to over 2.6 million vending machines: meaning that with approximately 122 million residents, there’s approximately one vending machine for every 45 to 50 people. 

But it turns out these contraptions of convenience had quite a long history before they became popular in Japan. It’s a story that left us wondering: Just how did vending machines become so ubiquitous in this Asian country, and what’s the science behind how they work? 

To get some answers, Popular Science turned to David Widjaja, former vending machine employee and current owner of Japantogo LLC, an Ishikawa-based exporter of Japanese vending machines, to give us the inside scoop. 

A brief history of vending machines

Famous Greek engineer and inventor Hero of Alexandria created the world’s first known vending machine in ancient Egypt during the first century AD. Hero utilized the powers of physics to dispense holy waters in temples. Hero’s dispenser used a simple counterweight lever system (picture the scales of justice, with two hanging pans held by a horizontal beam that adjusts its position, depending on which pan is heavier). When someone dropped a coin into the contraption, the coin would land on one of the scale’s pans. The weight of the coin would then trigger a valve and let out a flow of holy water. 

Engraving depicting an ancient penny-in-the-slot vending machine.
Famous Greek engineer and inventor Hero of Alexandria created the world’s first known vending machine in ancient Egypt to dispense holy water. Image: Universal History Archive / Contributor / Getty Images / Universal History Archive

Despite its ingenuity, the concept of vending dispensers pretty much disappeared until the late 19th century. That’s when coin-operated machines filled with postcards, envelopes, and notepaper began popping up on railway platforms throughout London for travelers on-the-go. 

Soon, the device made its way across the pond. By 1888, the Thomas Adams Gum Company was placing vending machines stocked with Tutti-Frutti chewing gum all along New York City’s transit lines. Before long, vending machines offered everything from cartons of milk to refrigerated sandwiches

Still, it wasn’t until after World War II that vending machines became a staple of Japanese culture. It happened during the country’s rapid postwar economic recovery. 

“They’re very convenient,” says Widjaja. “Japanese people are often in a rush, and we want something on the go. If you go into the store, it can cost you four or five minutes of waiting.” With vending machines, you can get what you need immediately. 

How do vending machines work?

Vending machines rely on an embedded computer system, which is a specialized computer system designed for a specific use. In this case, the embedded computer consists of a microcontroller (a tiny, self-contained computer), sensors, and actuators (the gear motors and pusher tracks that open access hatches and get that soda to fall). 

“Actually, vending machines are simple,” says Widjaja. The microcontroller acts as the machine’s “brain.” It receives user input (e.g. when you push your numbered selection), validates payment, and sends commands to the dispensing motors—the rotary power sources for each individual item. 

Related 'Ask Us Anything' Stories

How do garbage trucks work?

4 sunscreen myths too many people still get wrong

No, cruise ships aren’t floating petri dishes

Airplane seats really are getting smaller

Why you never forget how to ride a bike

It’s illegal to pump your own gas in New Jersey. But why?

Why are airplanes so cold? It’s for your health.

Payment validation

Once you put coins or paper money into a vending machine, the machine uses electromagnetic sensors to verify that the payment is legit. These sensors figure out which kinds of coins are inserted—and whether or not they’re authentic—by using electric and magnetic fields to determine a coin’s metal makeup. Basically, each metal alloy (e.g. nickel, iron, etc) produces a specific effect on the magnetic field. 

For example, when cheap iron passes through the machine’s magnetic lines it becomes temporarily magnetized. On the other hand, pure aluminum can pass through these same magnetic lines with little effect. The machine’s microcontroller will then instantly compare these results against a pre-programmed database of real coins, determining  whether the coin inserted is real or fake. 

At the same time, optical sensors measure the coin’s diameter, thickness, and speed. When a coin rolls down the vending machine’s chute, it casts a shadow on a light sensor. The microcontroller times exactly how long the light remains blocked. This allows it to calculate the coin’s precise diameter. Another light sensor measures how fast the coin is traveling, which helps the microcontroller confirm if it is moving abnormally fast or slow. If it’s one or the other, the coin is likely fake. The machine will then reject it.

For paper money, optical sensors use infrared and UV light sensors to read hidden security markings and magnetic ink (banknotes are printed with special magnetic inks containing iron oxide). 

If you’re using a credit card, the machine will send encrypted data through an attached telemetry gateway device—a hardware unit that collects data from the machine’s sensors—straight to a banking network. This allows the microcontroller to instantly verify if your payment is legitimate. 

Dispensing 

After your payment is accepted and you’ve punched in the code for your desired soda or bag of chips, the microcontroller switches modes. This tiny brain then sends a signal to the dispensing motor assigned to the object that you’re purchasing. 

Some machines use spiral coils that rotate 360 degrees and push a bag forward until it tips over the edge of the shelf. Others use robotic elevator arms or picker mechanisms that rise to a specific shelf, secure a drink, and gently lower it to prevent it from exploding. 

There are also machines that utilize a traditional gravity and drop system, in which the selected product simply slides off a slanted shelf and falls directly into the retrieval bin. 

Ramen Noodles Vending Machine in Tokyo thumbnail
Ramen Noodles Vending Machine in Tokyo
In Japan, some vending machines even dispense bowls of hot ramen. Video: Ramen Noodles Vending Machine in Tokyo, TabiEats

How Japanese vending machines differ

Many vending machines also include small refrigeration units to keep things cold, or internal built-in microwaves and instant heaters (long, narrow internal pipes that heat up to 2,000 Watts within seconds) for warm drinks like coffee and tea. 

However, dual-temperature machines that disperse both hot and cold products from the same unit are rare in the United States. That’s not the case in Japan, where Widjaja says vending machines are all about efficiency. “You can sell cold drinks during summer, and hot coffee during winter, all from one machine.” 

These specialized units feature two separate, heavily insulated zones: one for hot beverages and one for cold beverages. Many modern dual-temperature vending machines also feature an innovative heat-pump system—one that recycles the thermal energy generated from the machine’s cooler side and pipes it into its warm section. This helps to significantly reduce the machine’s overall energy consumption. 

Because Japan is prone to natural disasters, many of its vending machines are also designed to be “earthquake proof.” Their heavy parts, such as thick metal bases and compressor pumps that are actively circulating refrigeration gases to keep products cold, are built into the machine’s lower portion. 

“We call this area the ‘basement,’” says Widjaja. The bottom-lying weight helps to steady the machines in earthquake zones. “In Japan, everything is about safety.”

Another feature: free-dispense activation. “We call it ‘free vending,’” says Widjaja. Say there’s a large earthquake in Tokyo. These machines may have built-in sensors that detect heavy shaking, or are programmed to receive signals from local city authorities. In either case, “a router inside automatically switches to ‘free mode.’ The machine will then disperse free drinks so that everyone can have a beverage.” 

Although the number of vending machines in Japan has recently been decreasing, in a country with very low crime and millions of pedestrians on foot they still make sense. 

“Japanese people like a lot of options,” says Widjaja. “Vending machines have these options, and you don’t have to wait in line!”

In Ask Us Anything, Popular Science answers your most outlandish, mind-burning questions, from the everyday things you’ve always wondered to the bizarre things you never thought to ask. Have something you’ve always wanted to know? Ask us.

 
2026 Home of the Future header

2026 Popular Science Home of the Future Awards

 

Laura Kiniry

Contributor

Laura Kiniry is a freelance journalist based in San Francisco, California. Follow her on Instagram at @laurajkin