Pages: [1]   Go Down
Author Topic: Problem with running a Servo With Arduino Pro mini  (Read 1053 times)
0 Members and 1 Guest are viewing this topic.
Manchester, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I am using a Arduino pro mini connected to computer via USB cable (with six pin header at other end to connect pro mini)  to run servo motor..... but the servo motor goes to angle 0 and jiggles at that position .... i just tried to run servo sweep in examples......
note: blink led in examples in running fine with this.....

i am struggling to find out what is wrong in it ?   ....  can anyone suggests possible solutions to this??

Thanks in advance
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9686
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The most common issues with servos are 1) trying to power a servo from the arduino power supply, 2) the servo and arduino grounds are not connected, and 3) everything else such as bad code.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Manchester, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi zoomkat,

common Ground problem ...... thanks i solved that ..... but the servo sweep example i am running have a problem again.... it rotates upto 100 or 110   deg and comes back to zero in a loop....but actually it should go upto 180 deg.... is this means that Pro mini (3.3v, 8Mhz) is unable to provide high PWM signals for rotating higher degrees?????.... what should i do


Thanks
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Servo library doesn't provide PWM signals, it provides PPM signals.
It may be that your servo is incapable of rotating 180 degrees - the 0..180 convention of the Sero library bears no relation to how far the servo can actually turn.
Or your software may be incorrect (hint).
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9686
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple servo test code you can try to see if the servo moves as expected.

Code:
// 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() {
  Serial.begin(9600);
  myservo.writeMicroseconds(2000); //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);  // 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();

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  }
}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Manchester, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to all,

 Servo fault i think mistake was mine and i now running a new servo......now the servo works fine ....

Thanks again
Logged

Pages: [1]   Go Up
Jump to: