#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
int keyUp = 10;
int keyDown = 11;
void setup()
{
pinMode(keyUp, INPUT_PULLUP);
pinMode(keyDown, INPUT_PULLUP);
md.init();
}
void loop()
{
if(digitalRead(keyUp)== HIGH && digitalRead(keyDown)== HIGH)
{
md.setM1Speed(0);
}
if(digitalRead(keyUp)==LOW)
{
md.setM1Speed(400);
}
if(digitalRead(keyDown)==LOW)
{
md.setM1Speed(-400);
}
}
So i have put this sketch together to control forward and reverse of my motor. The key up and down is part of my on off on switch. As soon i turn power on to my motor control shield (VNH5019 dual channel remapped to single channel) and the Arduino is plugged in my motor starts to spin without me turning my switch on.