Problem with PinChangeInt library

Hello,

I am using PinChangeInt library (2.40-rc2 version) for creating interrupts in my Arduino. It works fine, however, I am trying to use getInterruptedPin() function of the library and it doesn't compile because it seems not being implemented, but in fact it is defined.

I have Arduino UNO ATMEGA328 with the Arduino IDE 1.6.6. In my case I have declared the following interruptions:

void setup() {
  Serial.begin(9600);    // Open the serial Port
  pinMode(LED_RD, OUTPUT);
  pinMode(LED_GRN, OUTPUT);
  pinMode(LED_BL, OUTPUT);
  pinMode(BUT_RD, INPUT);    //PIN 4
  pinMode(BUT_GRN, INPUT);  //PIN 3
  pinMode(BUT_BL, INPUT);    //PIN 2
  digitalWrite(LED_GRN, LOW);
  digitalWrite(LED_BL, LOW);
  digitalWrite(LED_RD, LOW);
  attachPinChangeInterrupt(BUT_RD, buttonTrigger, RISING);
  attachPinChangeInterrupt(BUT_GRN, buttonTrigger, RISING);
  attachPinChangeInterrupt(BUT_BL, buttonTrigger, RISING);
  led[0] = led[1] = led[2] = false;
}

And what I am doing in buttonTrigger() is:

void buttonTrigger() {
  if (turnInterrupt) {
    int pin = getInterruptedPin();
    if (digitalRead(pin)) {
      led[pin - OFFSET] = true;
    }
  }
}

I only have included "#include <PinChangeInt.h>". Finally, the error message is:

Arduino: 1.6.6 (Windows 10), Board: "Arduino/Genuino Uno"


\libraries\PinChangeInt-master/PinChangeInt.h:61:35: error: 'getArduinoPin' is not a member of 'PCintPort'

 #define getInterruptedPin()       PCintPort::getArduinoPin()

                                   ^

\Arduino_says.ino.ino:37:15: note: in expansion of macro 'getInterruptedPin'

     int pin = getInterruptedPin();

               ^

exit status 1
Error compiling.

Is there any solution? Or what am I doing wrong?

Thanks!

This problem is on line 439. Yes, that must be it. Yep, for sure.

Please reread your post and then tell us what information you've provided, other than you're trying to use the pinChangeInit Library. Do you notice a glaring lack of detail? What processor or Arduino board? Which pin? What error? Which IDE? Which OS?

Please start over again and this time, read the sticky notes at the top of this forum thread listing for how to use the forum properly.

You will only get useful answers when you ask coherent questions, with relevant supporting information, rather than just making statements.

I don't see "getArduinoPin()" defined anywhere in PCintPort:

Or what am I doing wrong?

You did not post ALL of your code as the per instructions I pointed you to. Posting fragments prevents others from duplicating your problem and finding a solution.

The compilation problem is due to the fact that you tried to do something from perhaps mixing code from similar but incompatible libraries.. You're calling a function that doesn't exist.

You could have avoided all this pain by using the examples that are packaged with the library. Had you done that, you would found an example that demonstrates any three input pins detected using interrupts. Look under the "Examples" menu pick and scroll down until you find "PinChangeInit" and select "PinChangeIntExample328". Compile it first with no changes and then make changes on step at a time, compile and test each change and you'll have a working solution.

In this message I attached the header of PinChangeInt library. In the line 50-51 it says:

If you want to see what the last pin that triggered an interrupt was, you can get it this way:
getInterruptedPin()

So the function I mentioned clearly exists, but it doesn't work as it is not implemented, at least as far I know about programming. Maybe the author forgot about it. Anyway, I find out how to get the last PIN that caused an interrupt. Is using PCintPort::arduinoPin; which returns the number of the pin. I found this in PinChangeExample256 which is also attached here.

I really would like to know why getInterruptedPin() is not implemented and instead they use PCintPort::arduinoPin; in that example.

PinChangeIntExample2560.ino (4.29 KB)

PinChangeInt.h (21.4 KB)

You'll find in the world of free open source software that quality is hit and miss and often the documentation is incomplete, incorrect, outdated, or missing altogether. People write 3rd party libraries on a volunteer basis so they tend to put more effort to the fun parts and many programmers don't consider writing and updating documentation to be fun. Since that function is mentioned several times in the source code and also in the wiki, I'd guess that it did exist at one time and was removed for some reason, maybe because the author decided that the global variable should be used instead but forgot to update the documentation. I really like the documentation driven development approach. Update the documentation and then update the code. It seems counterintuitive at first but it works great.

I think it's unfortunate that the Arduino world puts so much emphasis on the use of examples to document libraries. Examples are great but they're no substitute for actual documentation.