I have an Arduino Uno, pololu VHN 5019 Motor driver (linked below) and I'm trying to drive a single servo in addition to the 2 motors driven by the motor controller. The problem is that the motor controller uses pins 9 & 10 and can't be remapped according to the user manual.
Arduino Servo Library: arduino.cc/en/Reference/Servo (states pins 9 & 10 are disabled when in use)
My only option is to figure out how to use the servo without the standard library from what I understand? Does anyone have suggestions programmatically how to solve this problem? I tried detaching the servo immediately after moving it, but the motors continue to not work.
My only option is to figure out how to use the servo without the standard library from what I understand? Does anyone have suggestions programmatically how to solve this problem?
You can't get round it because the servo library is using the same timer as the PWM. This is known as conflicting resources, trying to use one thing twice.
The only way round it is to use other pins for your PWM, there are four more on a Uno. Or use a processor with more timers like a Mega.
Copy the .cpp and .h files from the link I gave or follow the link on this page Creative Robotics – Creating unique machines
Put them in a folder called ServoTimer2 in the libraries folder where your sketches are saved. Don't forget to shut down and restart the IDE to make the library available.
UKHeliBob:
Copy the .cpp and .h files from the link I gave or follow the link on this page Creative Robotics – Creating unique machines
Put them in a folder called ServoTimer2 in the libraries folder where your sketches are saved. Don't forget to shut down and restart the IDE to make the library available.
It doesn't seem to compile (same as the files from previous links), giving me the following error:
In file included from sketch_mar30a.ino:1:
C:\Program Files\Arduino\libraries\ServoTimer2/ServoTimer2.h:71: error: 'byte' does not name a type
C:\Program Files\Arduino\libraries\ServoTimer2/ServoTimer2.h:72: error: 'byte' does not name a type
C:\Program Files\Arduino\libraries\ServoTimer2/ServoTimer2.h:86: error: 'boolean' does not name a type
C:\Program Files\Arduino\libraries\ServoTimer2/ServoTimer2.h:106: error: 'boolean' does not name a type
Edit:
This is from the following code, btw:
#include <ServoTimer2.h>
void setup() {}
void loop() {}
It would also help if there were any examples, thanks.
I managed to get it to work, thanks for all the help. For anyone in the future that needs the library, I compiled it into a zip file with all the modifications and created an example sketch that should work (at least for me it does).
(I personally hate it when people fix a problem and don't include a final fix), Enjoy...
Dm.
Instructions:
Unzip folder and place into "libraries" folder of arduino.
Thanks used it and it works
i searched google for hours till i found this post
dmor574:
I managed to get it to work, thanks for all the help. For anyone in the future that needs the library, I compiled it into a zip file with all the modifications and created an example sketch that should work (at least for me it does).
(I personally hate it when people fix a problem and don't include a final fix), Enjoy...
Dm.
Instructions:
Unzip folder and place into "libraries" folder of arduino.