Go Down

Topic: Stumped on my first servo motor project (Read 1 time) previous topic - next topic


So I followed this guide on youtube:

The problem I'm seeing is that instead of going from 10degrees to 170degrees at the specified time I get:
The motor jerks every second even though I said every 10 seconds.  It jerks forward the whole time until its reached its limits... then it does nothing else. 

The motor is a "TowerPro MG995"
According to this spec: http://robotbase.en.alibaba.com/product/461190134-211878901/Tower_Pro_MG995_Servo_Motor.html it should work fine with 5volts.


Simple servo test code. Also, most standard size servos won't power well from an arduino. They usually need a seperate power supply.

Code: [Select]

// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
      Serial.print("writing Microseconds: ");
      Serial.print("writing Angle: ");

    readString=""; //empty for next input

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


You were right Zoomkat.  I hooked up an external power supply and it worked.

Go Up