I am using an Arduino Uno to control an ESC for my (in progress) quadrocopter. I am currently using the servo library to control the ESC, which works great.
Except..
A count of 100 is max speed, meaning I only have 10 speeds between 90 (stopped) and 100 (motor at full power) to correctly run my quadrocopter, I would like to have many more speed options. Any ideas? I'm having a hard time using a PWM signal, I might not be doing it right though.
My current code is here:
#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(8); // attaches the servo on pin 8 to the servo object
}
void loop()
{
int maxspeed=100;
int minspeed=0;
int delaytime=5;
int count;
for(count=0; count <1; count+=1) {
for(pos = minspeed; pos < maxspeed; 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(delaytime); // waits 15ms for the servo to reach the position
}
for(pos = maxspeed; pos>=minspeed; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(delaytime); // waits 15ms for the servo to reach the position
}
if(count>1){
break;
}
}
myservo.write(92);
delay(100000);
myservo.write(90);
delay(10000000);
}