beautypg.com

Pololu Dual VNH5019 User Manual

Page 14

background image

delay(2);

}

for (int i = 400; i >= -400; i--)

{

md.setM1Speed(i);

stopIfFault();

if (i%200 == 100)

{

Serial.print("M1 current: ");

Serial.println(md.getM1CurrentMilliamps());

}

delay(2);

}

for (int i = -400; i <= 0; i++)

{

md.setM1Speed(i);

stopIfFault();

if (i%200 == 100)

{

Serial.print("M1 current: ");

Serial.println(md.getM1CurrentMilliamps());

}

delay(2);

}

for (int i = 0; i <= 400; i++)

{

md.setM2Speed(i);

stopIfFault();

if (i%200 == 100)

{

Serial.print("M2 current: ");

Serial.println(md.getM2CurrentMilliamps());

}

delay(2);

}

for (int i = 400; i >= -400; i--)

{

md.setM2Speed(i);

stopIfFault();

if (i%200 == 100)

{

Serial.print("M2 current: ");

Serial.println(md.getM2CurrentMilliamps());

}

delay(2);

}

for (int i = -400; i <= 0; i++)

{

md.setM2Speed(i);

stopIfFault();

if (i%200 == 100)

{

Serial.print("M2 current: ");

Serial.println(md.getM2CurrentMilliamps());

}

delay(2);

}

}

This example ramps motor 1 speed from zero to max speed forward, to max speed reverse, and back to zero again
over a period of about 3 seconds, while checking for motor faults and periodically printing the motor current to the
serial monitor. It then performs the same process on motor 2 before repeating all over again.

Note: Even if you don’t have any motors yet, you can still try out this sketch and use the motor
indicator LEDs for feedback that the shield is working properly.

Pololu Dual VNH5019 Motor Driver Shield User’s Guide

© 2001–2014 Pololu Corporation

3. Getting Started with an Arduino

Page 14 of 28