How to remap conflicting pins from Arduino shields

I have the Mega 2560, the Ethernet Shield and the Motor Shield.

I’m attempting to use some code from StartingElectronics http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-IO/ and the Ethernet shields and Motor shields use the same pins.

Motor shield
Motor 1 → 3, 9, 12
Motor 2 → 8, 11, 13

Ethernet shield
A0, A1, 4, 10, 11, 12, 13

Is there a way to remap pins 11, 12, and 13?

As the pins are not "mapped" you can't "remap" them.

Mark

The Ethernet shield needs SPI that is mapped to pins 10-13 so you will have to move the motor shield pins. Put the motor shield on a breadboard and patch wire between it's needed pins and spare arduino pins. Then modify any code/libraries used by the motor shield to reflect the pin changes.

Riva: The Ethernet shield needs SPI that is mapped to pins 10-13 so you will have to move the motor shield pins. Put the motor shield on a breadboard and patch wire between it's needed pins and spare arduino pins. Then modify any code/libraries used by the motor shield to reflect the pin changes.

Awesome idea! I never would have thought of that.

I'll definitely have to look at it tonight.

It is the normal Ethernet Shield ? http://arduino.cc/en/Main/ArduinoEthernetShield The SPI bus is used (pin 11, 12, 13) and pins for ChipSelect (pin 4, 10), so you can not change those. As far as I know, pin A0 and A1 are not used.

Which motor shield is it ? The official Arduino Motor Shield ? http://arduino.cc/en/Main/ArduinoMotorShieldR3 Pin 11, for example, is used as PWM output for the motor shield. That is also an SPI pin. Pin 12 and 13 are also used.

I should take a look at the libraries to see if the motor shield can use other pins. That will not be easy and I don't have a Motor Shield to test it.

I have the Mega 2560, the Ethernet Shield and the Motor Shield.

If that is the case, then there is no pin conflict. The Mega doesn’t use D11 to D13 for the SPI bus (edit: Neither does the newer ethernet shields with the ICSP socket). Those pins are available for general I/O, like for your motor shield. The SPI data lines connect to the shield through the ICSP connector.

Ah, thanks SurferTim. You are right. Now I want to know if the Ethernet Shield and Arduino Mega 2560 board are all version R3.

The Ethernet shield is an actual Arduino shield, not 100,% on the motor shield (but I think it is).

For the website that I was using, it said that the shield was using A0, A1, 4, 10, 11, 12, 13, but I didn’t see anything in the code that used those IOs.

But from the sound of it, there won’t be a conflict.

Thanks a lot, I do appreciate it!

The newer Ethernet shield uses D10 & D4 for slave selects and the ICSP pins for SPI data lines. That means the Ethernet shield must be connected directly to the arduino.

I do have the Ethernet shield directly on the mega board, but I didn't think the order in which they were attacked mattered, but it's definitely go to know.

I'll have to find out what version it is, hopefully it's the latest!

If it has an ICSP connector on the bottom, it is new enough.