Issue running Servo and Dual VNH5019 MC

I’m using this motor controller to power a basic tank robot, and I’m now trying to add a servo to it to give it some more functionality. When I added the Servo to my code the Motor Controller refused to work correctly, not outputting any current or changing the colors of the indicator LEDs. I traced the issue to the servo.attack(pin); command. I attached the servo to pins that were listed as unused on the Pololu site and this issue still occurred. Is there a fix for this? Thanks.

-JM

Hello, JM.

It issue sounds like a library conflict. Which Arduino board are you using? Please note that the Arduino Servo library and the Arduino library for the VNH5019 shield both use Timer 1 on the Arduino Uno, so they cannot be used together. You might try using the code in the “Controlling a servo with an Arduino Uno” section in the Zumo Shield for Arduino User’s Guide or finding another servo library for Arduino that uses a different timer.

- Amanda

The timer issue would explain it. I’ll look into that tomorrow at work, thank you for your help.

-JM

I’m running into an issue when using the code you directed me to on that link. I added it into my program, however the line in ‘setup’ that initializes the servo is causing an issue with another part of my program. I am getting input from an external source using the pulseIn command, typically it outputs values between 1000 and 2000, however the addition of this code has made it so I only read inputs of about 1400, and it does not change when it should. Do you know what might be causing this issue?
Thanks

-JM

I don’t have a good sense of what’s going on in your program. Can you post your entire code here?

- Amanda

I can’t post my code right now, but the basic issue is that after adding in the code to run a servo using Timer 2 I am unable to properly use the pulseIn(); code on digital pins that aren’t mentioned in the servo code you linked. Is there something in the servo code that modifies how the pulseIn command will work?

I was able to solve this issue. The code was skewing the inputs I was receiving, however, it was constant so I was able to remap the values. I really appreciate the servo code you showed me.
Thanks,
-JM