Pin-Change interrupts for Sonar

Mr-What:

robtillaart:
There exists a PINCHANGEINT lib - Arduino Playground - PinChangeInt -

yes, but it is inefficient and inapporpriate for my app. The above shows how to do it using pin-change interrupts.

It's my understanding that PINCHANGEINT is fairly efficient. The author seems very concerned with speed and from what I remember, the library is almost all port register driven. With that said, I haven't used it much nor done my own speed checks to know with certainty. My guess is that the overhead has a lot to do with trying to make a general-purpose library that works on multiple microcontrollers instead of hard-coded like you have done. I've considered adding a pin change interrupt method to NewPing, but it was overly complex to do with multiple pins and multiple microcontrollers, so that could be the issue.

Also, I've lost my desire now that I have a $19 Teensy 3.0 that has a hardware pin interrupt on every pin.

On a side note, have you considered using only 6 sensors so you can use just the hardware pin interrupts instead of messing with PINCHANGEINT?

Tim