Wire Library vs. Various Processors

I started a project with an Arduino UNO R3, but the software grew too large, so I bought a MEGA 2560. In my project, I talk to two peripherals using SPI, and LCD display and a DS1307 clock. Nowhere in my code did I need to identify the SDA/SCL pins: the Wire library apparently took care of that.

So here's my question. When I saddle up the MEGA, change the IDE to recognize the chip, and import the Wire library, does the library recognize the changed pinout for the MEGA? My guess is yes, since the library description mentions the MEGA, but I'd like to be sure before I begin a rewire effort.

Thanks in advance for any insights.

John Doner

jrdoner:
I started a project with an Arduino UNO R3, but the software grew too large, so I bought a MEGA 2560. In my project, I talk to two peripherals using SPI, and LCD display and a DS1307 clock. Nowhere in my code did I need to identify the SDA/SCL pins: the Wire library apparently took care of that.

So here's my question. When I saddle up the MEGA, change the IDE to recognize the chip, and import the Wire library, does the library recognize the changed pinout for the MEGA? My guess is yes, since the library description mentions the MEGA, but I'd like to be sure before I begin a rewire effort.

Thanks in advance for any insights.

John Doner

The SPI library (and wiring library) does not need to know the physical (or even the arduino abstraction pin name to operate) as the SPI is driven by internal hardware that are fixed to specific AVR pins, just like the hardware serial port for a Uno is only available on pins 0 and 1. So while the Uno and Mega does use different physical pin numbers for the SDA/SCL pins, this is not the results of the wire library or any other magic software trick. There was always a problem of shields using SPI to work for both Uno and Mega boards without some kind of physical jumper or switch option to choose which board type it was to work with. The R3 versions of the Uno and Mega attemped to solve the problem by defining two new physical shield pins dedicated to just SDA/SCL, they were added next to the Aref pin.

Lefty

Thank you, Lefty,

That is one cool idea.

John Doner