coin acceptor/Teaching the acceptor/06. Coin types and pulse values
Teaching the acceptor · 06 of 11

Coin types and pulse values

You choose how many pulses each coin sends, and that one choice decides what your sketch can work out. Proportional counts let it add up money by itself. Low counts are faster but mean nothing on their own.

Getting into the menu

Hold + and together for about two seconds. The display shows E.

  1. Press + to choose how many coin types you want, up to six. Press SET.
  2. The display shows P1. Set the pulse value for your first coin with + and , then press SET.
  3. P2, then P3, and so on for as many types as you asked for.
  4. When the last one is saved the display returns to E.

P1 is the first coin type, P2 the second. Which physical coin each one refers to is decided later, in training — P1 is whichever coin you feed at step A1.

The decision hiding in that menu

The pulse value is not a label. It is the only thing that leaves the acceptor about which coin went in, and the numbers you pick decide what a sketch can do with them.

Two ways to number the same coins
Proportional · 1 pulse = 5c
Pulse plan
One pulse is worth
5c
Slowest coin
1.0 s
Proportional
yes
Proportional, so the money adds up on its own. Every pulse is worth 5c and every coin is set to the right number of them, so a sketch can add 5c per pulse and never need to know which coin it was. The price is at the bottom of the table: a dollar is 20 pulses, which is about 1.0 s on the wire.

Both plans in that figure are the product's own documentation. The library's own value-mode example uses the proportional one; the printed quick-start guide recommends the low counts. They are not the same advice, and neither is wrong — they are for different modes.

Proportional: the money adds up on its own

Pick a unit — five cents is a good one — and set each coin to that many units.

CoinPulses
5c1
10c2
25c5
$120

Now a sketch can add five cents for every pulse it counts and never need to know which coin it was. That is what value mode does, and it is the only arrangement in which its total is trustworthy.

The cost is at the bottom of the table. A dollar is twenty pulses, which at Medium is about a second on the wire.

Low counts: fast, but the arithmetic is gone

CoinPulses
5c1
25c3
$15

The biggest coin now arrives in a quarter of a second, so coins can follow each other much more closely. But three pulses is not worth fifteen cents in any system — the counts have become names, and the sketch has to be told what each name means. That is mapped mode, and three modes is where the two are compared.

Use whole numbers

Work in cents, not dollars. Every total the library keeps is an unsigned integer, so setPulseValue(0.05) truncates to zero, which the library rejects — and rejecting it quietly leaves the default of one in place, so every pulse counts as a single unit and your total is a pulse count wearing a dollar sign. Five is the number to set.

When it does not work

The display shows E and the buttons do nothing

E is the resting state inside setup mode, and it is where you land between steps. From E, SET goes into training. To set pulse values you need to get into setup from the start: hold + and − together for two seconds. If the buttons genuinely do nothing, check the adapter — a sagging rail resets the acceptor's own computer.

The total my sketch reports is wrong, but the coin count is right

The pulse plan is not proportional, and the sketch is in value mode. Value mode multiplies pulses by a fixed rate; if 25 cents is set to 3 pulses at 5 cents a pulse, it will report 15. Either reprogram the coins proportionally or switch the sketch to mapped mode.

Two coins are set to the same pulse count

Then nothing anywhere can tell them apart — the count is the only information on the wire. The library refuses a duplicate: addCoin() returns false for a pulse count it already has, and begin() fails if no coin was added at all. Give each coin its own count.

How high can a pulse value go?

The acceptor will let you set counts higher than is sensible. The library refuses to map a coin above 50 pulses — addCoin() returns false and that coin is simply never recognised. At Medium, 50 pulses is two and a half seconds for one coin, which is already far past usable anyway.

Where this goes next

Fifteen of each, and what the display says while you count them.

Train it with real coins

Edit this page — content/books/coin-acceptor/coin-types-and-pulse-values.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Arcade Coin Acceptor Module Kit, USB-C Powered

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum