using interrupt pin 20 on Mega

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sgtserg
 
Posts: 24
Joined: Fri Oct 28, 2011 1:30 pm

using interrupt pin 20 on Mega

Post by sgtserg »

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.

User avatar
adafruit_support_bill
 
Posts: 88086
Joined: Sat Feb 07, 2009 10:11 am

Re: using interrupt pin 20 on Mega

Post by adafruit_support_bill »

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

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”