Not Getting Pulses from Coin Acceptor

Good day everyone! I need help on a project I'm working on right now. I'm using this Coin Acceptor and I'm not getting pulses every time I insert a coin, I know this because the LED pin supposed to light up and Number of pulses supposed to be printed on the serial monitor If I get pulses. LED and Serial Monitor only reacts when I remove the 5V pin. this is a schematic and program of the project.. I am using a 2W 10k ohm resistor.
image

// Constants
const int coinpin = 2;
const int ledpin = 13;

// Variables
volatile int pulse = 0;

boolean bInserted = false;

// Setup
void setup() {
 
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(coinpin), coinInterrupt, RISING);
  pinMode(ledpin, OUTPUT);
 
}

// Main loop
void loop() {
 if(coinpin == LOW) {
   Serial.print("high");
 }
 
  if( bInserted  ){ // for show LED ON when Inserted
     bInserted = false;
     digitalWrite(ledpin, HIGH);    
     delay(1000);
  }else{
   
  // Turn off LED
  digitalWrite(ledpin, LOW);
  } 
}

// Interrupt
void coinInterrupt(){
 
  // Each time a pulse is sent from the coin acceptor,
  // interrupt main loop to add 1  and flip on the LED
  pulse++ ;
  bInserted = true;

 digitalWrite(ledpin, HIGH);
 Serial.println( pulse );
   
}

What are the characteristics of the signal on the white wire?

Is it open collector? Is it 0-12V?

I'm guessing the 10K may be a pullup resistor. Maybe the output of the coin module is open collector? 2W seems rather excessive.

You shouldn’t print within an interrupt service routine .

The diagram looks like it's ok, so I don't know why it'd work without the pullup.
Anyway, assuming the yellow pin is open collector and brought to GND to send a pulse, first of all you have a few issues.
First, this code:
if(coinpin == LOW) {
does not check the pin value, because "coinpin" is the pin number, not its state.
Second, apart from avoiding printing within an ISR, you also must declare "volatile" all the variables changed by the ISR. Including bInserted.

Said that, I would explicitly declare the pin as INPUT, and you could even avoid the resistor if you declare the pin as INPUT_PULLUP.
I assume as a first stage you just want to check if a coin is inserted, and not the kind of it, so after you'll solve the current issue, as a next phase you will then need to count the pulses within a fixed amount of time.
So start with something like this (not tested, you must do it!):

// Constants
const int coinpin = 2;
const int ledpin = 13;

// Variables
volatile int pulse = 0;

// Setup
void setup() {
 
  Serial.begin(9600);
  pinMode(coinpin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(coinpin), coinInterrupt, FALLING);
  pinMode(ledpin, OUTPUT);
}

// Main loop
void loop() {
  if( pulse > 0 ) {
     digitalWrite(ledpin, HIGH);    
     delay(100);
    digitalWrite(ledpin, LOW);
  pulse = 0;
  } 
}

// Interrupt
void coinInterrupt(){
  pulse++ ;
}

That is never, ever going to be true.

-- this will take time away from the processing and you'll miss your coin pulses.

Also - you probably mean digitalRead(coinpin) == LOW

The whole thread is moot until the questions in reply #2 are answered. Need a spec sheet on the coin acceptor.

Is it possible that the coins you inserted are not valid? You would expect no pulse in that situation.

Yes its a pull up resistor.. What does it mean if its a open collector? should i try using different resistor?

I tried using this code. but still nothing.. The coin acceptor worked on my nodemcu with a premade code, and also didnt need to use a resistor last time so I dont think the coin acceptor is broken.

I dont think its not valid because if its not valid the coin acceptor wont receive it

Hello brownoutee

Post the data sheet of the coin acceptor to see how we can help.

I bought mine in a shop from the city and the box did not include a datasheet. also I was looking online and couldn't find one. But I found this online which is the same brand and style https://shopee.ph/UNIVERSAL-COIN-SLOT-MULTI-COIN-SELECTOR-i.158572255.2487983384

Look like a CH-923 with a black finish instead of chrome.

This video shows how to set it up and calibrate it.

Here is a 'manual' for a CH-926 which may be helpful.

Hi. I did setup the coin acceptor and also followed this video. but still no pulses. How to use CH-926 Coin Acceptor with Arduino - YouTube
Is there anyway I can check if the coin acceptor outputs on the coin pin.

Yes, use a multimeter or oscilloscope to view the output voltage when a coin is inserted.

Sorry but I dont have those. I havent tried it yet but would a digitalRead or maybe analogRead on a arduino pin show something?

Yes, you can even connect only an LED and resistor in such a way, it will illuminate with a pulse. You can write a simple sketch to echo the digital state of a pin to the on board LED, too.

coinslot1

would this light the led if a pulse comes out of the coin pin?

If the yellow output goes to 12V to send a pulse you could burn the LED. You need a partitor to drop the voltage to 5V (2 resistors from 12V to GND, but do you know how to get partitor resistors values?) and then another resistor to limit the current (typically 220 Ohms).