Arduino Continuous Rotation Servo


hello everyone,

i working on bot project , have taken portions of robot , spread them out. im working on wheels far. have 2 continuous rotational 'servos' powering wheels. having trouble code it. on basic stamp used pulsout() unreliable , sketchy, on arduino uno rev3 using, trying best rotating set amount of time. know not possible code in degrees want turn, using servo.microseconds(x) able delegate direction , how fast turns. x being 90, stays still, above 90 , turns clockwise, below goes counterclockwise.

my issue timing. want servo turn set amount of time. have tried loops, loops, while loops, , such. reason servo keeps spinning.

any suggestions helpful? run issue before?

just quick example of 1 of quick tests tried,

code: [select]
#include <servo.h>

int time=0;
int degree;
servo myservo;


void setup()
{
  myservo.attach(9);    //sets pin 9 servo
myservo.writemicroseconds(90);   // sets servo not spin
}

void loop()
{
  do
  {
    degree = 180;
    myservo.writemicroseconds(degree);
    delay(500);
    time = time + 1;
  } while (time < 20);
 
  myservo.writemicroseconds(90);
}


in example, servo continuously rotates, never stops , wont delay have set. seems gets stuck on myservo.writemicroseconds()

i think have 2 or 3 errors.

when use writemicroseconds() parameter must number between 1000 , 2000. still using degree values. 90 deg corresponds 1500 microsecs.

you have no delay() after writemicroseconds() after while loop there no time servo react.

you don't reset time 0 before while loop loop work once because after time have higher value test.

while not cause of problem have no serial.println() calls in code assist see going wrong.

...r


Arduino Forum > Using Arduino > Programming Questions > Arduino Continuous Rotation Servo


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support