Arduino uno and coin slot/coin acceptor auto-pulse

Hi guys, having problem with my arduino + coin slot. I just followed this diagram for my testing see attached file. Also got the code from this site: http://www.arduinotutorialonline.com/2017/12/coin-acceptor-with-arduino-programming.html credits to the owner.

My problem is that, when the 12v adaptor of coin slot is plugged-in and out. There’s a pulse sent from the coin slot. The same also when the 12v adaptor is not plug and I removed the pin from coin slot, it do the same. What else should I need to check? Thanks!

// 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( 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 );
   
}

coin_bb.jpg

Two things to try:
If the Arduino is powered by the 12v supply that powers the coin reader, you can use delay() statements in setup() to wait until everything has stabilized before accepting readings.
Maybe you need also a pullup resistor (external or internal) on coinpin.