ardupilot 2.5 programing

Hi guys, 

I am trying to implement the following code found in arduino' s website without any luck. Does the pin 4 actually represent pin 4 of the ardupilot output? please let me know. Just bought it yesterday and I cannot wait to start programming it. 

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(4); // attaches the servo on pin 9 to the servo object
}


void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

Thank you guys.

 

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Developer

    >Does the pin 4 actually represent pin 4 of the ardupilot output?

    No, you will need to look at the schematic for APM2.5+ see http://store.3drobotics.com/products/apm-2-5-kit for the 'Eagle' files which has the schematic. You can download Eagle to view it in (google it).

    Output PWM 4 = PG5 on the 2560 chip. To know what PG5 is google for 

    ATmega2560 datasheet it's on ATMEL site for free.

This reply was deleted.

Activity