The interrupt pin is pin D2 and what's triggering it is a coin acceptor.
Would that also be the case with coin acceptors? I did monitor the D2 pin with an oscilloscope. Everything is normal from the time the arduino is reading the impulse from the coin acceptor > turning on the relay > turning off the relay.
The only problem is sometimes after a cycle, my coin_imp variable goes up.
I tried inserting "Serial.println("Triggered");" in my interrupt code but it doesnt show in the serial monitor when i get the unwanted impulse.
so i just put the NoInterrupt() function on the loop right?
but since the Interrupt() function is called in the NoInterrupt() function wouldnt that call the interrupt() function without D2 having to call the interrupt?
It’s NOT your function. This is to deactivate and then reactivate the interrupts, this way you are sure nothing bad happens to the bytes whilst your loop plays with the variables. Of course you want to minimize the duration of the critical section, so that’s why you just make a copy of the values and then work from the copies