Go Down

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


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



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.


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.


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


I wonder if it is easier for you to just to download MegaServo from the playground and copy that into your hardware libraries directory.  

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

The rest of the sketch can remain unchanged

Go Up