If you could elaborate on what you mean by nothing happens, that would be great.
Looking at your code, I’m pretty sure it wont do what you think it should do. Always remember that microcontrollers will do exactly what you tell them to do, not necessarily what you want them to do.
Because the enable pin is also the fault pin, you don’t really want to drive it high. When the Arduino pin (connected to the enable pin) is set as an input (which it is in the init() function), there is a resistor pullup that enables the motor. To disable the motor, you set the pin to be an output, then drive it low. To re-enable the motor, you have to set the pin to be an input again.
Here is a little run down of what is and is not happening in your code:
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
int offPin = 6;
void setup()
{
pinMode(offPin, OUTPUT); //Sets pin to an output, and probably defaults low,
//which would disable the motor.
md.init(); //This then sets the pin back to an input, which re-enables the motor.
}
void loop()
{
md.setM1Speed(400); //The motor is set to run.
delay(2000);
digitalWrite(offPin,LOW); //This actually turns off the Arduino's internal pullups.
//(Which basically means it does nothing that affect the motor.)
//It does not drive the pin low since the pin was set to an
//input in the init(); function.
delay(2000);
}
This code will probably do what you expected from your program:
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
byte offPin = 6; //Just using less memory space with a byte instead of an int.
void setup()
{
md.init(); //Enables the motor
}
void loop()
{
md.setM1Speed(400);
delay(2000);
pinMode(offPin, OUTPUT); //This sets the pin to an output. and probably low but...
digitalWrite(offPin, LOW); //...This makes sure the pin is low to disable the motor.
delay(2000);
pinMode(offPin, INPUT); //This re-enables the motor so it can run again.
}
Unfortunately, I can’t test this program until at least tomorrow (or later today, depending on how to look at it considering the time.)
Edited to fix a small mistake in my program. Also, I tested it today and it works.