Hello everyone,
I am currently trying to solve an issue regarding the Pololu Dual VNH5019 Motor Driver Shield for the arduino. My goal is to be able to make the motors continuously move forward. If I can get passed this issue, I will be able to control all the directions of the motors. The library for the Motor Driver Shield can be found here as well as its example:
https://github.com/pololu/dual-vnh5019-motor-shield
I have tried to understand how it works, but I have had no luck with it. The only time it has worked is with a different program:
If anyone has any suggestions, questions, and/or an answer it would be appreciated!
I am currently trying to solve an issue regarding the Pololu Dual VNH5019 Motor Driver Shield for the arduino. My goal is to be able to make the motors continuously move forward. If I can get passed this issue, I will be able to control all the directions of the motors. The library for the Motor Driver Shield can be found here as well as its example:
https://github.com/pololu/dual-vnh5019-motor-shield
I have tried to understand how it works, but I have had no luck with it. The only time it has worked is with a different program:
C:
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
/*
#include <Servo.h>
Servo myservo;
*/
char dataIn='S';
char determinant;
char det;
int vel = 200; //Bluetooth Stuff
int overdrive = 13; //Press Toggle Switch #1, the pin13 LED will light up
void setup(){
Serial.begin(9600);md.init();
/*
myservo.attach(6);delay(100);
myservo.write(90);delay(100);
*/
}
void loop(){ det = check(); // You'll need to reconstruct this if your not using the Pololu Dual VNH5019
while (det == 'F') // F, move forward
{md.setSpeeds(vel,vel);det = check();}
while (det == 'B') // B, move back
{md.setSpeeds(-vel,-vel);det = check();}
while (det == 'L') // L, move wheels left
{md.setSpeeds(-vel,vel);det = check();}
while (det == 'R') // R, move wheels right
{md.setSpeeds(vel,-vel);det = check();}
while (det == 'I') // I, turn right forward
{md.setSpeeds(vel,vel/2);det = check();}
while (det == 'J') // J, turn right back
{md.setSpeeds(-vel,-vel/2);det = check();}
while (det == 'G') // G, turn left forward
{md.setSpeeds(vel/2,vel);det = check();}
while (det == 'H') // H, turn left back
{md.setSpeeds(-vel/2,-vel);det = check();}
while (det == 'S') // S, stop
{md.setSpeeds(0,0);det = check();}
//---------------------Toggle switch code------------------//
/*while (det == 'W'){myservo.write(180);delay(100);det = check();}
while (det == 'w'){myservo.write(90);delay(100);det = check();}
while (det == 'U'){myservo.write(0);delay(100);det = check();}
while (det == 'u'){myservo.write(90);delay(100);det = check();}
*/
}
int check()
{if (Serial.available() > 0) {dataIn = Serial.read();
if (dataIn == 'F'){determinant = 'F';}
else if (dataIn == 'B'){determinant = 'B';}else if (dataIn == 'L'){determinant = 'L';}
else if (dataIn == 'R'){determinant = 'R';}else if (dataIn == 'I'){determinant = 'I';}
else if (dataIn == 'J'){determinant = 'J';}else if (dataIn == 'G'){determinant = 'G';}
else if (dataIn == 'H'){determinant = 'H';}else if (dataIn == 'S'){determinant = 'S';}
else if (dataIn == '0'){vel = 400;}else if (dataIn == '1'){vel = 380;}
else if (dataIn == '2'){vel = 340;}else if (dataIn == '3'){vel = 320;}
else if (dataIn == '4'){vel = 280;}else if (dataIn == '5'){vel = 240;}
else if (dataIn == '6'){vel = 200;}else if (dataIn == '7'){vel = 160;}
else if (dataIn == '8'){vel = 120;}else if (dataIn == '9'){vel = 80;}
else if (dataIn == 'q'){vel = 40;}
else if (dataIn == 'U'){determinant = 'U';}else if (dataIn == 'u'){determinant = 'u';}
else if (dataIn == 'W'){determinant = 'W';}else if (dataIn == 'w'){determinant = 'w';}
}return determinant;}
I've tried working with it, however I can't understand what the issue is. The basic code that I have been trying to do is this:
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
int Foward = 200;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);md.init();
}
void loop() {
// put your main code here, to run repeatedly:
while (Foward == 200)
{md.setSpeeds(300, 300);}
}
If anyone has any suggestions, questions, and/or an answer it would be appreciated!
Last edited: