Teaching the acceptor · 05 of 11

The two switches

Two settings on the side of the acceptor decide how it reports a coin: whether the output rests open or closed, and how long each pulse lasts. NO and Medium are the ones the library expects, and Medium is a compromise you may want to revisit.

Output mode: NO

The first switch is marked NO / NC — normally open and normally closed. It decides which state the output rests in when nothing is happening, and therefore which direction a pulse goes.

Set it to NO. The library expects it: it configures the pin with an internal pull-up and counts falling edges, so it is waiting for a line that sits high and gets pulled down. On NC that is reversed, and the symptom is not "nothing happens" but the opposite — a stream of counts while no coin is anywhere near the machine.

Signal width: how long a pulse lasts

The second switch sets the width of each pulse:

PositionPulse width
Fast20 ms
Medium50 ms
Slow100 ms
Pulse width times pulse count is how long a coin takes
Medium · 50 ms · 5 pulses
Signal width switch
Pulses for this coin5
One pulse
50 ms
This coin takes
250 ms
Coins per second
4.0
Comfortable. 5 pulses at 50 ms is about 250 ms, so the acceptor is free again almost immediately. The library then waits 250 ms of silence before deciding the coin is finished, which is the real floor on how fast coins can be told apart.

The two numbers multiply, and that is the whole reason this switch is worth thinking about. A coin set to 20 pulses takes about 0.4 s on Fast and about 2 s on Slow, and for the whole of that time the acceptor is still talking about the first coin.

Why Medium

Medium is the recommended position, and it is a compromise rather than a best. A 50 ms pulse is long enough that nothing plausible misses it — even a sketch polling in a slow loop will see it — and short enough that ordinary pulse counts do not take absurdly long.

Move to Fast when coins will arrive quickly and you have already lowered the pulse values as far as they will go. Move to Slow essentially never; it exists for old machines reading the line with a relay.

The thing the switch cannot fix

Shortening the pulse shortens the train, but the library still waits 250 ms of silence before it decides a coin has finished. That wait is a floor no switch position gets under, and it is what why fast coins get missed is about. If coins arriving quickly is your problem, the lever with the most travel in it is the pulse count, not the pulse width.

When it does not work

The library counts pulses continuously with no coin inserted

The output mode switch is on NC rather than NO. On NC the line rests in the opposite state, so what the library sees as the idle level and what it sees as a pulse are swapped. Move it to NO.

Some pulses are counted and some are not

Try Medium if you are on Fast. A 20 ms pulse is plenty for an interrupt, but if the library has fallen back to polling — which happens on a GPIO that cannot take an interrupt — a loop with any delay() in it can step straight over one. Medium gives polling more room.

Coins are counted twice

That is the other end of the same problem, and it is usually a wiring one rather than a switch one: a long unshielded signal wire alongside a mains lead can pick up enough noise to look like an extra edge. Keep the signal wire short, and make sure the ground wire runs with it.

Which switch is which on my unit?

The labels are printed on the acceptor's side panel beside the switch bank — look for NO / NC for the output mode and Fast / Medium / Slow for the signal width. Set them before you bolt the acceptor into a panel, because that side faces into the cabinet.

Where this goes next

The menu that decides whether your sketch can add up money at all.

Coin types and pulse values

Edit this page — content/books/coin-acceptor/the-two-switches.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