Hello

I'm newbie arduino. 

my first targe is to control servo and ESC.

I succeed working servo by using ArduPilotMega_dancing tutorial.

but i want to work servo by using servo library (arduino example ... sweep? below example )

unfortunately,  this code is not working.

so.. i guess the problem.

maybe pin number is wrong?

or... ardupilot cannot use servo library?

and..

can you tell me how can control ESC ?

--------------------------------------------------------

// Sweep
// by BARRAGAN a href="http://barraganstudio.com>">http://barraganstudio.com>;
// This example code is in the public domain.


#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(9); // 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
}
}

Tags: ESC, servo

Views: 93

Reply to This

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service