   pinMode(INPUT_PIN, INPUT);
 
   // Attach interrupt to input pin
-  attachInterrupt(INPUT_PIN, notify, CHANGE);
+  attachInterrupt(INPUT_PIN, onPinChanged, CHANGE);
 }
 
 

}


void notify(){
  Serial.println("On interrupt");

  if(connected == true){
    // Read input and store
    uint8_t value =  0;
    if(digitalRead(INPUT_PIN) == HIGH){
      value = 1;
    }
  
    // Send 1 byte of data with value
    pCharacteristic->setValue((uint8_t*)&value, 1);
    pCharacteristic->notify();
    Serial.println("Notification sent");
  }
  else{
    Serial.println("Interrupted but not connected");
  }
}


#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

#define INPUT_PIN 33
#define DEBOUNCE_TIME_MICROS 35000

BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;

bool connected = false;
unsigned long lastValidReadTime = 0;


class BLECallback: public BLEServerCallbacks {
