Help me please i'm new to this and need to know how to control servos

Hey guys,

Im new to Arduino and decided for a first project to build a useless box (something simple) and i need to know if there is a way to on startup force a servo to a angle because the depth of my box is way less then the start position of the servo, i have got it so that once the switch is switched and returned to its original place the servo goes back to the angle i desire but i need this to happen straight away without having to do this.

Thanks.

FRIGNCRZY:
if there is a way to on startup force a servo to a angle

Try myServo.write(angle) immediately before myServo.attach()

Another option may be to find what is the "natural" position of the servo; attach the servo horn in that position and use different values for the movements that are harmonious with that physical arrangement.

Attaching a 4,700 ohm resistor between the servo signal wire and GND may also help to keep the servo still at startup - before the Arduino gets around to sending a servo signal.

...R

You can attach a servo before writing to it or vice versa, doesn't matter AFAICT.

The problem is that when the servo is powered up it will immediate go to midtravel
(or whatever its default is) until it sees a control signal.

The Arduino takes some time to initialize and until then the servo is actively holding
position at the default. Your Arduino code only starts to take effect when setup()
is called, not at power up (the bootloader gets control initially and listens for a
sketch download for a little while before giving up and passing control to you sketch.

The servo start position, or neutral, is controlled by the servo. It will move to that position without any signal, when power is applied. No way around it. The neutral position can be changed by rotating the pot inside it, or the control arm on the shaft. You may also rotate the servo's position.

steinie44:
The servo start position, or neutral, is controlled by the servo. It will move to that position without any signal, when power is applied.

In my experience this behaviour varies between servos. Some of them seem only to respond to noise on the floating signal connection. I have found that a 4k7 resistor between the signal wire and GND keeps them quiet.

...R

Robin2:

FRIGNCRZY:
if there is a way to on startup force a servo to a angle

Try myServo.write(angle) immediately before myServo.attach()

Another option may be to find what is the "natural" position of the servo; attach the servo horn in that position and use different values for the movements that are harmonious with that physical arrangement.

Attaching a 4,700 ohm resistor between the servo signal wire and GND may also help to keep the servo still at startup - before the Arduino gets around to sending a servo signal.

...R

Ok thanks for that i will try them all but thanks heaps :slight_smile: