Pages: 1 [2]   Go Down
Author Topic: 2 tests and 2 failures - what am I doing wrong?  (Read 1451 times)
0 Members and 1 Guest are viewing this topic.
London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, there is a line in the Servo.cpp, in Servo::attach,  that says:
Code:
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.
Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a million mem - it works!!!!!  I'm very pleased  ;D

I thought you had to use PWM to drive a servo yet the new MegaServo library can drive it on nealy all the digital pins ... how?

How long has that code been in the playground?  I hadn't seen that before?

Thank you again!  

Now - what do I have to do to make the 3 axis sensor work?
Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The MegaServo library was written when the Mega board was released, around the beginning of April.

I have not played with that 3 axis board but suggest you google for information on SPI with the Mega board to see what needs to be done to get it working.

Good luck!
Logged

Pages: 1 [2]   Go Up
Jump to: