Go Down

Topic: 2 tests and 2 failures - what am I doing wrong? (Read 1 time) previous topic - next topic

mem

You may want to try the MegaServo library,  you can use the same code but any pin will work.

http://www.arduino.cc/playground/Code/MegaServo

RuggedCircuits

Well, there is a line in the Servo.cpp, in Servo::attach,  that says:
Code: [Select]
if (pinArg != 9 && pinArg != 10) return 0;
So basically the code as written forbids any other pins than 9 or 10.

Maybe it's safe to just take this line out, maybe not. Some library revision might be in order.

mem

That line should have been amended when the Mega chip support was added. It is worth removing it as a temporary fix but the code should check the currently selected board and test for the correct pins.

As mentioned above, the MegaServo library does not have this problem and can use any available pin on any of the Arduino boards.

jparry

Sorry to ask a stupid question but I am quite new to this - how do I access that section of the code?

mem

I wonder if it is easier for you to just to download MegaServo from the playground and copy that into your hardware libraries directory.  
http://www.arduino.cc/playground/Code/MegaServo

In the sketch, change
 #include <Servo.h>
to
#include <MegaServo.h>

The rest of the sketch can remain unchanged

Go Up