Code not working for servo>?

Hello forum mates, I am currently testing out a ldx 227 digital servo and am having some strange issues.

When i connect it to the arduino ( external power of course) and use the sweep sketch, it works perfectly fine. The oroblem is when I try to make it do something simple like move 90 degrees, it somehow doesnt work now?

Hello forum mates, I am currently testing out the LDX 227 digital servo and am having unexpected problems.

When connecting the servo via PWM to the Arduino (with external power), it does not move when I try to make it move a certain angle. This is strange because I can get the servo to move with the Arduino sweep function?

The code is very very simple, so I’m not sure what’s happening. Any help is appreciated.

#include <Servo.h>

Servo Arm1;

void setup() {
  // put your setup code here, to run once:


void loop() {
  // put your main code here, to run repeatedly:


The code look fine.

Check your wiring then check it again. How is the servo powered ?
Does the sweep example work with the servo on pin 5 ?
Are you sure that the servo is not already at 180 ?

Why have you started 2 threads for the same problem ?

The servo is powered with 4 nimh as batterys.

For the sweep, I changed the servo.attach to pin 5.
I have tried many different angles, none of them work.

I'm not really sure why this is happening.

Sorry, it was an accident. :frowning:

Sorry, it was an accident. :frowning: slow motion.

Threads merged.

I have tried many different angles, none of them work.

Try with 2 different angles, with a second or so delay between...

If you have a potentiometer try the Knob sketch. If the servo works when you move the potentiometer slowly but fails when you move it fast then that is a symptom of not enough power. I don't know exactly what a "nimh as battery" is but perhaps they need charging or if you mean AA or AAA batteries you may need bigger batteries for that large servo.

Sweep isn't very good at showing up power problems because it always moves in small increments which put less load on the servo.


Alright, I will try that

They are AA rechargable batteries in one of those 4 cell holders.

Hi, I am facing with the same problem, looks like we got attracted by dual shaft.
I however made a solution: Try using for loop. for example if you need to go from 30 degree to 70 degree-

for(pos = 0; pos <= 70; pos += 1)
delay(15);    //at least 15ms is needed as I found

This sends pulses for 0 to 70 degrees and after a delay (cuz 0 to 29 is not used) the servo will rotate.
But if I use

or(pos = 3; pos <= 70; pos += 1)

This doesn’t work.

That’s all I have till now. If you have found any solution to this please tell us. Thank you.

This doesn’t work.

What do you see when you print the value of pos within the for loop ?
Where is pos declared ?

Better still, post a complete program that illustrates the problem. The Sweep example would be a good place to start