using interrupt pin 20 on Mega
Moderators: adafruit_support_bill, adafruit

using interrupt pin 20 on Mega

by sgtserg on Sun Mar 03, 2013 11:48 pm

Hello,
I read that the arduino mega has four interrupt pins. I wanted to use pins 20-21, but these pins are also used for I2C. I tried writing a simple code to test the interrupt using these pins but no luck. When I used pin 19 it worked fine. I'm wondering if the reason that these pins are not working is because I need to declare these pins to be for interrupt. Thanks.
sgtserg
 
Posts: 24
Joined: Fri Oct 28, 2011 12:30 pm

Re: using interrupt pin 20 on Mega

by adafruit_support_bill on Mon Mar 04, 2013 7:16 am

You need to use the AttachInterrupt() function. Interrupt pins on the Mega are: 2, 3, 21, 20, 19, 18
http://arduino.cc/en/Reference/AttachInterrupt

You can also use pin-change interrupts on pins 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
http://playground.arduino.cc/Main/PinChangeInt
User avatar
adafruit_support_bill
 
Posts: 29014
Joined: Sat Feb 07, 2009 9:11 am