This is a follow-up on my last post. Chris, you got it to move with the arming help! Thanks!
The issue now is the motor will spin but keeps stopping and trying to reverse, and then spin again. I have tried playing around with the arming angle, but the motor always seems to stop and back up, as if trying to correct its angle. Is there a way to prevent this? I think it may be from my attachments to the motor, which make it start up slow. This is for a "tuna-can spinner" sumo and I have a piece of wood mounted horizontaly and a dowel rod verticaly, so the weight may be the issue here =). Is there a way to have it go only in one direction?
Here is my updated code:
// this uses the Arduino servo library included with version 0012
// caution, this code sweeps the motor up to maximum speed !
// make sure the motor is mounted securily before running.
#include <Servo.h>
Servo myservo;
void arm(){
// arm the speed controller, modify as necessary for your ESC
setSpeed(0);
delay(1000); //delay 1 second, some speed controllers may need longer
}
void setSpeed(int speed){
// speed is from 0 to 100 where 0 is off and 100 is maximum speed
//the following maps speed values of 0-100 to angles from 0-180,
// some speed controllers may need different values, see the ESC instructions
int angle = map(speed, 0, 100, 0, 180);
myservo.write(angle);
}
void setup()
{
myservo.attach(9);
arm();
setSpeed(100);
delay(1000);
setSpeed(0);
delay (1000);
}
void loop()
{
int speed;
for(speed = 0; speed < 100; speed++) {
setSpeed(speed);
delay(10);
}
}