I'm working on a project that makes use of a CH926 coin acceptor. The problem we're having is that when I read the serial monitor, the coin value is continuously going up and adding credits when it's supposed to remain at 0 until a coin Is fed into the acceptor.

We've tried a different coin acceptor, different codes, arduinos, wiring, resistors, breadboards, the lot. nothing seems to be solving this problem and we can't determine why, it had been working fine until we tried to tidy up our wiring and untangle it.

we're using a basic code that had worked fine up until we had the issue of the counter value no longer remaining at 0:

const int coinpin = 2;
const int ledpin = 3;
const int targetcents = 100;

// Variables
volatile int cents = 0;
int credits = 0;

// Setup
void setup() {

  attachInterrupt(digitalPinToInterrupt(coinpin), coinInterrupt, RISING);
  pinMode(ledpin, OUTPUT);


// Main loop
void loop() {

  // If we've hit our target amount of coins, increment our credits and reset the cents counter
  if (cents >= targetcents) {
    credits = credits + 1;
    cents = cents - targetcents;

  // If we haven't reached our target, keep waiting...
  else {

  // Debugging zone
  Serial.print(" cents toward current credit and ");
  Serial.println(" credit(s) earned so far.");

  // Turn off LED
  digitalWrite(ledpin, LOW);

  // Now, write your own cool code here that triggers an event when the player has credits!
  if (credits > 0) {
    // Play music?
    // Spin up a motor?
    // Start a game?
    // It's up to you!


// Interrupt
void coinInterrupt(){

  // Each time a pulse is sent from the coin acceptor, interrupt main loop to add 1 cent and flip on the LED
  cents = cents + 1;
  digitalWrite(ledpin, HIGH);


any advice on what may be causing this problem?


  • 4
    Sounds like a floating input. Check your pullup / pulldown resistor on coinpin. – Majenko Dec 2 '19 at 12:09
  • 2
    In addition to what @Majenko said, I have the following idea: Since the Sensor is powered by 12 V I guess you power it externally. Have the external power and the Arduino a common ground connection? I.e. did you connect the GND of the external power and a GND Pin of the Arduino. Perhaps you did it in your first setup but forgot it after rewiring. – Peter Paul Kiefer Dec 2 '19 at 13:38
  • if the coin acceptor worked until you tidied up the wiring, then why are you posting code? ... why did you say nothing about the wiring? – jsotola Dec 2 '19 at 15:29
  • 2
    "...it had been working fine until we tried to tidy up our wiring and untangle it." Wait, what? Your hardware/software system was working fine until you made a hardware change (trying to tidy up the wiring) and now it isn't working, so you decide it must be the software? Why does that make any sense? If it worked fine until you made a hardware change, shouldn't you focus on hardware problems? You almost certainly messed up some of the wiring. Focus on that. – Duncan C Dec 3 '19 at 1:18

I'm also complicated by that. The advice I saw here was to connect a COIN wire also against an electric "R" 10K and connect to the second hole on the left in the Arduino "IOREF" now it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.