So, I've been working with this motor shield for a fairly large robot, though the code I've written only seems to work on arduino Megas, not Unos. The problem here is that I want to use an Uno, but for some reason I cant (btw pulsein is for my controller). Here's the code I've written :
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
int power = (((pulseIn(3, HIGH, 25000))-1000)/1.125)-400; //Gives us a value that is within the range of the motors. (-400 -> +400)
float direct = (((pulseIn(5, HIGH, 25000))-1000)*0.1111111111111111)/100; //Gives us a percentage ( 0 -> 1 value )
void stopIfFault()
{
if (md.getM1Fault())
{
Serial.println("M1 fault");
while(1);
}
if (md.getM2Fault())
{
Serial.println("M2 fault");
while(1);
}
}
void setup()
{
Serial.begin(9600);
md.init();
pinMode(3, INPUT);
pinMode(5, INPUT);
}
void loop()
{
Serial.print(" 1:");
Serial.print(direct);
Serial.print(" 2:");
Serial.println(power);
if(direct > -50 && direct < 50)
{
power = (((pulseIn(3, HIGH, 25000))-1000)/1.125)-400;
direct = (((pulseIn(5, HIGH, 25000))-1000)*0.1111111111111111)/100;
md.setM1Speed(power);
md.setM2Speed(power);
stopIfFault();
}
if(direct < -50 || direct > 50)
{
power = (((pulseIn(3, HIGH, 25000))-1000)/1.125)-400;
direct = (((pulseIn(5, HIGH, 25000))-1000)*0.1111111111111111)/100;
md.setM1Speed(power * direct);
md.setM2Speed(power * (1 - direct));
stopIfFault();
}
delay(10);
}
For some reason , when I use the uno, no LEDs light up indicating that power is going through, but when using an arduino mega it seems to work fine. I'm at a loss for answers. Can someone help me out?