Stacking Arduino Wifi Shield and Arduino Motor Shield

Hello,

I am working on a project to control a gutted remote control tank via Arduino Uno. I want to send directional information via Wifi and tap into the tank's two bidirectional motors using a motor shield.

My question: is there a Wifi shield and motor shield that can stack and play well together on an Arduino Uno (or another model if necessary)?
I'd like to have a strategy before I begin buying shields :slight_smile:

I looked at the Arduino Wifi Shield (Arduino Wi-Fi Shield - DEV-11287 - SparkFun Electronics) and it looks like pins 11-13 are used, but are SPI bus communications.
The Arduino Motor Shield(http://www.makershed.com/Official_Arduino_Motor_Shield_p/mksp12.htm) uses pins 11-13 as well.
I'm a newbie when it comes to shields and EE, but does the SPI bus communication mean I could stack these shields?

Thanks for any guidance or advice.
Brent

You must get away from digital pins 11-13 with the wifi. That is the reason I use the Mega 2560. If you use an Arduino wifi shield, that device uses the ICSP pins for the SPI bus. On the Mega 2560, you are clean.

I am also working on a project and was hoping to use the WiFi shield and Motor shield together. I'm new and a little hesitant to clip pins yet. Does anybody think there's a chance that one could buy the Motor shield kit, from which I understand you wire the shield together yourself, and simply build it to use non conflicting pins? If anybody's done this, I'd love to hear how. Otherwise, I'm bumping this thread in hopes someone can help.

The wireless SD shield works fine with the motor shield (see hardware ref). You can get a wifi module with the same pinout as the XBee's

Mark

Hi holmes4,

From documentation,http://arduino.cc/en/Main/ArduinoWirelessShield

it looks like the Arduino Wireless SD shield also uses pins 11-13

Included on board is a SD card slot. When using the SD Library to access the card, Pin 4 is CS and cannot be used otherwise. SPI also relies on pins 11, 12, and 13 for communication.

Were you using them together with a Mega? I would be really interested to know because I'd like to use them both together also (motor shield + wireless SD)

Thanks

tz

Success! You are correct Holmes4, the two shields work together

I was able to set up a stack: arduino-uno + arduino motor shield + arduino wireless SD shield + xbee

and use it to make an RC car. You just need to make sure not to attach any additional sensors to the pins that motor-shield uses, i.e..,

Function Channel A Channel B


Direction: Digital 12 Digital 13
Speed (PWM): Digital 3 Digital 11
Brake : Digital 9 Digital 8
Current Sensing: Analog 0 Analog 1

Although it seems like you can use those pins for other stuff, but then the function assigned to pin in the motor shield won't work.

If anyone is interested I'd be happy to post an example.

tz

I should have said that you can't use the SD card if you do this.

Mark

I tried to stack and had problems … So I am attempting to change pins by using an Arduino Proto shield… I just need help figuring out what pins I am forgetting to get the board to work… Pins I have moved so far 3, 9, 8, 13, 11, and 12, but I can’t get the motor shield to power up and operate… my question is are there any other pins that need power or any thing? please help!

Which Arduino, which motor shield, which WiFi shield, what was the problem and why move more than 4 pins? and you may need to post your code.

Mark

Arduino Uno
Arduino Wireless SD shield with RN-XV
Arduino Motor shield

I recently purchased from sparkfun.com… I was wanting to make an internet controlled tank bot using the motor and tank tread from the Popular Mechanics RC Tank…
My current roving tank bot with out internet control or the Wireless SD shield looks like this:

#include <Servo.h>

int signal=7; //ping signal
int distance;
int bumper_R = 5;
int bumper_L = 6;
int bumper_R_val;
int bumper_L_val;
int leftDistance, rightDistance;
Servo panMotor; //ping sensor servo

unsigned long pulseduration=0;

void setup(){
pinMode(signal, OUTPUT);

//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin

//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel B pin
pinMode(8, OUTPUT); //Initiates Brake Channel B pin

panMotor.attach(10,.5,2.3);
panMotor.write(90);
pinMode(bumper_R, INPUT);
digitalWrite(bumper_R, HIGH);
pinMode(bumper_L, INPUT);
digitalWrite(bumper_L, HIGH);
Serial.begin(9600);
}

void measureDistance()
{
// set pin as output so we can send a pulse
pinMode(signal, OUTPUT);
// set output to LOW
digitalWrite(signal, LOW);
delayMicroseconds(1);

// now send the 5uS pulse out to activate Ping)))
digitalWrite(signal, HIGH);
delayMicroseconds(1);
digitalWrite(signal, LOW);

// now we need to change the digital pin
// to input to read the incoming pulse
pinMode(signal, INPUT);

// finally, measure the length of the incoming pulse
pulseduration=pulseIn(signal, HIGH);
}

void loop()
{
// get the raw measurement data from Ping)))
measureDistance();
// divide the pulse length by half
pulseduration=pulseduration/2;
bumper_R_val = digitalRead(bumper_R);
bumper_L_val = digitalRead(bumper_L);
// now convert to centimetres. We’re metric here people…
distance = int(pulseduration/29);
int distanceFwd = distance;
// Display on serial monitor
Serial.print(“Distance - “);
Serial.print(distance);
Serial.println(” cm”);
// when characters arrive over the serial port…
if (bumper_R_val == 0){
digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(8, HIGH); //Engage the Brake for Channel B
delay(100);
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //back up
delay(1250);
digitalWrite(12, LOW); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //turn left
delay(1000);
}
else if (bumper_L_val == 0){
digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(8, HIGH); //Engage the Brake for Channel B
delay(100);
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //back up
delay(1250);
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //turn right
delay(1000);
}
else if (bumper_L_val == 0 || bumper_R_val == 0){
digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(8, HIGH); //Engage the Brake for Channel B
delay(100);
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //back up
delay(1250);
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //turn right
delay(1750);
}
else if (distance >= 20 || distance <= 0) {
// wait a bit for the entire message to arrive
delay(100);
digitalWrite(12, LOW); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed
}
else {
digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(8, HIGH); //Engage the Brake for Channel B
panMotor.write(-20);
delay(350);
measureDistance();
measureDistance();
pulseduration=pulseduration/2;
distance = int(pulseduration/29);
rightDistance = distance ; //scan to the right
delay(400);
panMotor.write(190);
delay(430);
measureDistance();
measureDistance();
pulseduration=pulseduration/2;
distance = int(pulseduration/29);
leftDistance = distance; //scan to the left
delay(400);
panMotor.write(90); //return to center
delay(300);
compareDistance();
}
delay(100);
}

void compareDistance()
{
if (leftDistance>rightDistance) //if left is less obstructed
{
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //turn left
delay(1000);
}
else if (rightDistance>leftDistance) //if right is less obstructed
{
digitalWrite(12, LOW); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //turn right
delay(1000);
}
else //if they are equally obstructed
{
digitalWrite(12, HIGH); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed //Do 180
delay(1250);
}
}