Skip to content

Can't control a servo once detach()ed (2.0.0-rc2) #1133

Closed
@kotobuki

Description

@kotobuki

The following code works as expected with my Arduino Uno board, but doesn't work with my ESP8266 based board. Once a servo is detached, the code can't control the servo anymore. According to the Library Manager, the version of the Servo library is 1.1.0.

#include <Servo.h>

Servo servo;

const int servoPin = 2;

void setup() {
  servo.attach(servoPin);
  servo.write(90);
  delay(500);
  servo.detach();
  delay(500);
}

void loop() {
  servo.attach(servoPin);

  servo.write(60);
  delay(500);
  servo.write(120);
  delay(500);
  servo.write(90);

  servo.detach();
  delay(500);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions