Go Down

Topic: Setting a servo to a position (Read 956 times) previous topic - next topic

NickB

Ok, so 2 of my 3 servos are now working beautifully (not entirely sure what I did). However the last servo (servoBase) is still driving into its leftmost stop, regardless of what its being told to do. When the code is running, if you grab the servo and manually turn it to the right, it will try to drive back to the left. Here is the code I am using.
Code: [Select]
#include <Servo.h>

Servo servoBase;   
Servo servoLowerarm;
Servo servoUp;
               
  void setup()
  {

    servoBase.attach(9);  // attaches the servo on pin 9 to the servo object
    servoLowerarm.attach(13);
    servoUp.attach(11);
  }


void loop()
{
   servoBase.write(170);   //0 left
   servoUp.write(180); //180 all up lowest servo
   servoLowerarm.write(180);  //180 all up higherservo
   delay(2000);
   servoBase.write(120);
   delay(1000);
   servoUp.write(125);
   delay(900);
   servoBase.write(180);
   servoUp.write(120);
   servoLowerarm.write(180);
   delay(3000);
   servoUp.write(180);
   delay(1000);
   servoLowerarm.write(90);
   delay(2000);
}



The servo is a HItec HS-422 and it does work fine on other programs. I have tried changing the angle and the pin it is assigned to, but so far nothing has worked. I have no Idea what is wrong. I am new at this and may simply be over looking a simple error.

Thanks

zoomkat

I would suspect you have a bad ground connection between the servo and the arduino. If the other servos just started working for no reason  (maybe you bumped their wiring or similar), then wiring/connection for that servo is probably bad. Try jiggling its wiring.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

PeterH


The servo is a HItec HS-422 and it does work fine on other programs.


Do you mean that if you leave the hardware alone and upload a different sketch, you can get it working? If so that's significant because it points to a software problem, whereas all the other evidence seems to suggest a wiring fault.
I only provide help via the forum - please do not contact me for private consultancy.

NickB


I would suspect you have a bad ground connection between the servo and the arduino. If the other servos just started working for no reason  (maybe you bumped their wiring or similar), then wiring/connection for that servo is probably bad. Try jiggling its wiring.


This was the issue.
Thank you everybody for the help! 

Go Up