COIN or COUNTER: pick one wire
The module hands out two signal pins and you only wire one. COIN sends a burst whose length says which coin. COUNTER sends one pulse per accepted coin and nothing else. On the smallest coin they look identical, which is how the confusion starts.
One coin, two wires
Drop the same coin in and both wires respond, differently. COIN sends as many pulses as that coin is programmed for. COUNTER sends exactly one, whatever the coin was.
That single pulse is a genuinely useful fact — something was accepted — and it arrives immediately rather than after a train of pulses has finished. If your project is a door, a dispenser, a game that starts, or anything where one coin buys one thing, COUNTER is the simpler wire and there is nothing to program wrong.
Which wire answers which question
| You want to know | Wire | Why |
|---|---|---|
| A coin arrived | COUNTER | One pulse, immediately, no counting |
| How many coins so far | COUNTER | Count the pulses |
| How much money so far | COIN | The pulse count carries the value |
| Which coin it was | COIN | Same reason |
The one-pulse coincidence
Test with a coin programmed to one pulse and the two wires do the same thing. It is easy to conclude from that test that COUNTER is just a second COIN pin, wire COUNTER, write a money-totalling sketch, and then discover that every coin adds the same amount.
Test with your largest coin instead. The difference is immediate and obvious.
Both idle high
Whichever you pick, the pin sits at your board's logic voltage when nothing is
happening and is pulled down to ground for each pulse. The library sets the pin
to INPUT_PULLUP and counts falling edges, which is why the acceptor's output
mode switch has to be on NO — see the two
switches.
That is also why an unconnected signal pin does not read as a stream of coins. The pull-up holds it high, which is the idle state, and nothing happens.
When it does not work
It reads one, by design. A CoinAcceptor object is constructed with a single pin. Wiring both does no harm but tells the library nothing extra, so pick the one that answers your question and leave the other off.
Check which pin the wire is actually on. On the module the MCU-side header runs GND, VCC, COIN, COUNTER, and COIN is the pin next to VCC — one row up from where people expect COUNTER to be. It is the commonest miswire on this board.
Use COIN in mapped mode, which fills in both totalCoins() and totalValue(). COUNTER cannot give you value under any arrangement, because the value information is never on that wire.
You can construct two, but only the first to call begin() gets the interrupt — the library allows one interrupt instance and the second silently falls back to polling. That makes the second one far easier to lose pulses on, so it is not a good way to get both facts. Mapped mode on one wire is.
What the library actually fills in, and the accumulator each mode leaves at zero.
Three modes, and which one you want →Edit this page — content/books/coin-acceptor/coin-or-counter.mdx
Questions about this product
See what other owners have asked, and read their solutions.
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.