Skip to content

Servo: Calling write() before attach() causes problems #839

Closed
@chrisfraser

Description

@chrisfraser

In other servo libraries calling write() or writeMicroseconds() before attach sets the initial position of the servo on attach.

This causes the servo to not work in the latest staging release. See code to reproduce below.

#include <Servo.h>

Servo servo;

int servoPin = 13;

void setup()
{
  servo.writeMicroseconds(544);

  servo.attach(servoPin);

  delay(3000);
}

void loop()
{
  int us;

  for (us = 544; us <= 2400; us += 2)
  {
    servo.writeMicroseconds(us);
    delay(3);
  }
  for (us = 2400; us >= 544; us -= 2)
  {
    servo.write(us);
    delay(3);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions