One of the cool things about this shield design is that it is possible to stack shields. Every shield you stack can control another 2 steppers or 4 DC motors (or a mix of the two)
You can stack up to 32 shields for a total of 64 steppers or 128 DC motors! Most people will probably just stack two or maybe three but hey, you never know. (PS if you drive 64 steppers from one of these shields send us a photo, OK?)
Note that stacking shields does not increase the servo connections - those are hard-wired to the Arduino digital 9 & 10 pins. If you need to control a lot of servos, you can use our 16-channel servo shield and stack it with this shield to add a crazy large # of servos.
Stacking shields is very easy. Each shield you want to stack on top of must have stacking headers installed. Check our instructions for how to do so. The top shield does not have to have stacking headers unless you eventually want to put something on top of it.
The only thing to watch for when stacking shields is every shield must have a unique I2C address. The default address is 0x60. You can adjust the address of the shields to range from 0x60 to 0x7F for a total of 32 unique addresses.
Each board in the chain must be assigned a unique address. This is done with the address jumpers on the lower edge of the board. The I2C base address for each board is 0x60. The binary address that you program with the address jumpers is added to the base I2C address.
To program the address offset, use a drop of solder to bridge the corresponding address jumper for each binary '1' in the address.
The right-most jumper is address bit #0, then to the left of that is address bit #1, etc up to address bit #4
Board 1: Address = 0x61 Offset = binary 0001 (bridge A0 as in the photo above)
Board 2: Address = 0x62 Offset = binary 0010 (bridge A1, to the left of A0)
Board 3: Address = 0x63 Offset = binary 0011 (bridge A0 & A1, two rightmost jumpers)
Board 4: Address = 0x64 Offset = binary 0100 (bridge A2, middle jumper)
The Adafruit_MotorShield library has the ability to control multiple shields, unlike the older AF_Motor library. First we must create a Motor Shield Controller for each shield, with the assigned address.
Adafruit_MotorShield AFMSbot(0x61); // Rightmost jumper closedOne motor shield is going to be called AFMSbot (bottom shield, so we remember) and one is AFMStop (top shield) so we can keep them apart. When you create the shield object, specify the address you set for it above.
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
Then we can request the motors connected to each one
// On the top shield, connect two steppers, each with 200 stepsYou can request a stepper or DC motor from any port, just be sure to use the right AFMS controller object when you call getMotor or getStepper!
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 1);
Adafruit_StepperMotor *myStepper3 = AFMStop.getStepper(200, 2);
// On the bottom shield connect a stepper to port M3/M4 with 200 steps
Adafruit_StepperMotor *myStepper1 = AFMSbot.getStepper(200, 2);
// And a DC Motor to port M1
Adafruit_DCMotor *myMotor1 = AFMSbot.getMotor(1);
Then, both shields must have begin called, before you use the motors connected
AFMSbot.begin(); // Start the bottom shieldYou can try out this code for yourself by setting up two shields and running the File->Examples->Adafruit_MotorShield->StackingTest example
AFMStop.begin(); // Start the top shield