servo motor abnormal behaviour


hi guys

greetings , many many such nice , cooperative forum. new field bought arduino mega controller , mg995 servo motor. followed tutorials , copy paste circuit servo not stopping @ continuously rotating though input angle. code write follows.
#include <servo.h>

int pos=0;
int servodelay = 25 ;
int servopin = 2 ;

servo firstservo ;

void setup() {
  serial.begin( 9600) ;
  firstservo.attach ( servopin ) ;
 
}

void loop() {
 serial.println (" want position servo ?");
  while ( serial.available() == 0 ) { }
  pos = serial.parseint() ;
  firstservo.write(pos) ;
 
}

it continuously rotating though input angle.
are using continuous rotation servo or normal 180 degree servo?

you cannot move continuous rotation servo specific angle - can control speed , direction. should stop servo.writemicroseconds(1500); may need vary number or down suit particular servo.

for learning servos better use program not need input on serial connection because never know whether problem receiving data or controlling servo. try servo sweep example comes arduino ide.

...r


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > servo motor abnormal behaviour


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'