Introduction: Using More Than 4 Motors - Stacking Multiple Motorshields

Instructable Vibrotactile Sensory Substitution and Augmentation Device (https://www.instructables.com/id/Vibrotactile-Sens...) shows a way of how to build a device that translates a sensory input into vibratory stimuli. Those vibratory stimuli are produced by cylindrical ERM motors that are driven by an Arduino Uno with a motorshield.

For more than 4 motors, multiple motorshields need to be stacked.

In case more than 6 motors need to be independently driven, you need more PWM pins than the Arduino Uno has (6 PWM pins) and therefore an Arduino Mega. Theoretically, more than two shields can be stacked on an Arduino, however consider that Arduino Mega also only has a limited amount of PWM pins: 15.

Supplies

Prototype from https://www.instructables.com/id/Vibrotactile-Sens....

Step 1: Soldering and Stacking

  • Solder stacking pins on both motorshields as visible in the pictures
  • Solder address jumpers on one of the boards (see explanation on picture and https://learn.adafruit.com/adafruit-motor-shield-... for more detailed instructions of doing so)
  • Stack Arduino and both shields atop each other.
  • Make sure that the VIN Jumper is on both shields.

Step 2: Code

This is an example of how to let 8 motors translate 3 sensory values:

  1. Download the code, provided in a zip folder below, open it and install libraries, as explained in ....
  2. Click on Tools Board → select Arduino/Genuino Mega or Mega 2505
  3. Change following parts in the code, if needed

Define each motor with its pin number and shield:

Adafruit_DCMotor *motor1 = AFMS1.getMotor(1);             // specify that DC motors connected to first shield<br>Adafruit_DCMotor *motor2 = AFMS1.getMotor(2);          
Adafruit_DCMotor *motor3 = AFMS1.getMotor(3);          
Adafruit_DCMotor *motor4 = AFMS1.getMotor(4);          
Adafruit_DCMotor *motor5 = AFMS2.getMotor(1);             // specify that DC motors connected to second shield
Adafruit_DCMotor *motor6 = AFMS2.getMotor(2);      
Adafruit_DCMotor *motor7 = AFMS2.getMotor(3);          
Adafruit_DCMotor *motor8 = AFMS2.getMotor(4);

Specifiy the number of used motors:

int nrOfMotors = 8;

Include all used motors in an array:

Adafruit_DCMotor *motors[8] = {motor1, motor2, motor3, motor4, motor5, motor6, motor7, motor8,
};

Include all sensorpins in an array:

unsigned char sensorpins[3] = { A15, A14, A13,
};

Upload the Code to Arduino Mega. Done.

Step 3: Make It Wearable

In the Instructable about how to make the SSAD wearable (https://www.instructables.com/id/Making-the-SSAD-W...), an example of how to attach an Arduino Uno and one motorshield to the body is given. If you have to use the Arduino Mega and multiple motorshields, a hip bag, like illustrated in the sketch might be a solution for making the prototype wearable.