Coin Slot Sensor Using AttachedInterrupt Hi Im having a problem on my code How can I properly use the attached Interrupt on my coin Sensor so that it will not have any problem on detecting coins
#include &lt;Adafruit_Fingerprint.h&gt;    //Libraries needed
#include &lt;SoftwareSerial.h&gt;
#include &lt;Wire.h&gt;
#include &lt;LCD.h&gt;
#include &lt;LiquidCrystal_I2C.h&gt;
#include &lt;EEPROM.h&gt;
#define I2C_ADDR 0x27          //LCD i2c stuff
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
const int coinSlot = 9;
int relayPin = 4;

String Names[] = { &quot;RAVEN&quot;, &quot;Surtr&quot;, &quot;Tech&quot;,}; //Those are the names affected to the fingertemplates IDs
//The first on which is Names[0] : &quot;&quot; has the ID 1 in the fingerprint sensor

SoftwareSerial mySerial(2, 3);                  //Fingerprint sensor wiring RX 3, TX 2
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); //LCD declaring

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&amp;mySerial);                    //Fingerprint sensor declaring

volatile int coinCount = 0;
int requiredCoins = 1;
boolean coinInserted = false;

void setup()
{
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);
  pinMode(coinSlot, INPUT_PULLUP);
  lcd.write(EEPROM.read(5));
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(9), coinInterrupt, FALLING);
  finger.begin(57600);              //Sensor baude rate
  lcd.begin (16, 2);
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.setCursor(0, 0);
  lcd.print(&quot;SECURED VAULT&quot;);
  lcd.home();
  finger.getTemplateCount();        //Counts the number of templates stored in the sensor flash memory
  delay(2000);
}

void loop() {
  int FingerPrintResult = getFingerprintIDez();

  if (FingerPrintResult != -1) { //This function keeps looping and waiting for a fingerprint to be put on the sensor
    OpenDoor();
  }
  else
  {
    if (coinInserted) {
      coinInserted = false;
      coinCount++;

      EEPROM.write(0, coinCount);
      Serial.println(EEPROM.read(0));

      lcd.setCursor(0, 0);
      lcd.print(&quot;TOTAL:&quot;);
      lcd.setCursor(0, 1);
      lcd.print(coinCount);
    }

    void coinSlot() {
      coinCount++ ;
      insert = true;

      else {
        lcd.clear();
      }
    }
  }
}
//Only the modifications are commented
int getFingerprintIDez() {
  uint8_t p = finger.getImage();        //Image scanning
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();               //Converting
  if (p != FINGERPRINT_OK)  return -1;

  lcd.clear();                     //And here we write a message or take an action for the denied template
  p = finger.fingerFastSearch();     //Looking for matches in the internal memory
  if (p != FINGERPRINT_OK) {         //if the searching fails it means that the template isn't registered
    lcd.print(&quot;Access denied&quot;);
    delay(2000);
    return -1;
  }
  //If we found a match we proceed in the function

  lcd.print(&quot;Welcome&quot;);                  //Printing a message for the recognized template
  lcd.setCursor(2, 1);
  lcd.print(Names[finger.fingerID - 1]); //Then print the name we gave it and the -1 is to remove the shift as the ID starts from &quot;1&quot; but the array from &quot;0&quot;
  return finger.fingerID;
}
void OpenDoor() {
  digitalWrite(relayPin, LOW); // turn on solenoidlock
  delay(5000);
  digitalWrite(relayPin, HIGH); // turn off solenoidlock
}

Please how can I get the code working and what line of code should I focus to make the code work
Again, it makes sense to just use an attachInterrupt capable pin; but if can't for some reason:
Library install
Applying what I suggested in the answer on your other question to the code you've provided here, means installing the mentioned library:

And searching for and installing the library from the manager:

Code changes
Including the header
Patterned after documentation and an example for the library, your code would need to include the header for the library:
#include &quot;PinChangeInterrupt.h&quot;

Replacing attachInterrupt
Your attachInterrupt call would need to change to attachPinChangeInterrupt; likewise with the function that maps the pin to the interrupt number:
attachPinChangeInterrupt(digitalPinToPinChangeInterrupt(9), coinInterrupt, FALLING);


That is about all there is to it.  On the UNO/Nano or broadly ATMega328P-based Arduinos, only pins 2 and 3 work with attachInterrupt.  attachPinChangeInterrupt will work with most pins of most AVR-based Arduinos; any pins that have an PCINTn signal routed to them.  These are not as desirable to use, for performance reasons that you don't need to worry about for push buttons or your coin detector, and for easy-of-use reasons that are taken care of for you by this library.