Go Down

Topic: More than 2 External Interrupts ? (Read 3407 times) previous topic - next topic


I am trying to use 3 Quadrature Encoders at the same time.  

I realize that attachInterrupt can only use 2 encoders.  

Is there a way to write a software interrupt to read an additional encoder?


Not sure, I have heard that some AVR chips have  a port change interrupt that will generate an interrupt if any of the 8 bits in a specific port change state. If that is so then maybe it's possible, but not sure the Arduino IDE/core supports it directly.

I do know the new Arduino mega board has 5 user interrupt pins available.




Thanks,  PCINT code looks viable,

Has anyone made a library out of the PCINT code ?


Jul 31, 2009, 02:57 am Last Edit: Jul 31, 2009, 04:00 am by pgrunwald Reason: 1
Hi - I'm trying to use the PCINT code and getting the below errors when I try and compile in the IDE (build 0016) on a Duemilanove 328.

error: expected constructor, destructor, or type conversion before string constant In function 'void PCattachInterrupt(uint8_t, void (*)(), int)':
In function 'void PCdetachInterrupt(uint8_t)':
In function 'void PCint(uint8_t)':

Any suggestions?


You need to put in a pointer to a function name. The origional code had it as:-
void PCattachInterrupt(uint8_t pin, void (*userFunc)(void), int mode) {

So in this case you need a function to be called on interrupt called usrFunc - in the error message you posted you don't appear to have a function.

I used the interrupt on change in one of my recent projects:- http://www.thebox.myzen.co.uk/Hardware/Crazy_People.html have a look at the code to see how I implemented it.


Thanks Mike,  I will take a look.  The Pcint example code (http://www.arduino.cc/playground/Main/PcInt)  throws the same error when compiled unmodified.

Best regards,

Go Up