0

I am building a rather complicated model railroad crossing signal and have moved to using the Mega since I need more pins than the Uno. Upon reading the specs of the Mega on the Arduino.cc website I noticed a potential pin conflict, or not, maybe they serve a dual purpose?

External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt 3), and 21 (interrupt 2).

I2C: 20 (SDA) and 21 (SCL).

SDA and Interrupt 3 both function on pin 20? Likewise with Interrupt 2 and SCL?

I assume this is true, how/why do they share the same pin?

asked May 2, 2016 at 23:01

1 Answer 1

1

Lots of things share pins. It's normal. The "how" is that those pins are connected, internally, to multiple bits of the circuitry.

The "why" is simply because if you had a discrete pin for each possible function you would end up with a chip the size of your desk.

Pretty much every single pin on the chip has multiple functions on it.

answered May 2, 2016 at 23:07
7
  • Then can you define two things with the same pin? #define INTERRUPT_3 20 and then #define I2C_SDA 20? Commented May 2, 2016 at 23:21
  • You can define anything to anything. You can only use one function at a time though. After all - how would you wire the pin to both the I2C device and the interrupt source and differentiate between them? Commented May 2, 2016 at 23:22
  • 1
    So if I plan on using interrupts AND I2C, then effectively I can't use interrupt3? Commented May 2, 2016 at 23:25
  • And interrupt 2. Still, you have pin-change interrupts on every single other pin on the board... Commented May 2, 2016 at 23:32
  • Not on the Mega you don't. Commented Oct 30, 2016 at 6:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.