stop()

Description

Stops a rotating servo. After calling this function, the servo stops at its current position. The set target angle and time are cleared, and the current angle becomes the target angle. This function behaves differently from pause() . You cannot resume the servo using resume() . You must reset the target angle and then call either run() or write() to restart the servo. Note that the servo will still produce force after being stopped. Do not manually rotate it too hard, as this may damage the servo.

Syntax

servo.stop()

Parameters

servo: A variable of type AIServo.

Postback

None

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

#include <AIServo86.h>

 

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo;

 

void setup()

{

  bus.begin(Serial3, 1000000);

  myservo.attach(bus, 3);

  myservo.write(150);  // Turn the servo to 150 degrees

  myservo.run(); //Start the server

  delay(600);

}

 

void loop()

{

  myservo.setPosition(280, 2000); // Set the servo's target angle to 280 degrees and time to 2 seconds

  myservo.run();

  delay(1000); // Let the servo rotate for 1 second

  myservo.stop(); // Stop the servo

  while(1);

}

See also

- attach()
- setPosition()
- pause()
- resume()


Library Reference Home

The text in the 86Duino reference is adapted from the Arduino reference and is licensed under the Creative Commons Attribution-Share Alike 3.0 License. The code examples in the reference materials have been released into the public domain.