26 lines
713 B
C++
26 lines
713 B
C++
|
|
/*
|
|
"Jerks"
|
|
This example demonstrates the servo drive movement
|
|
with a sharp stop in both directions
|
|
*/
|
|
|
|
#include <Servo.h>
|
|
|
|
Servo servo; // create an Servo class instance to control the servo
|
|
|
|
void setup() {
|
|
servo.attach(8); // connecting the servo drive to digital pin 8 (D8)
|
|
}
|
|
|
|
void loop() {
|
|
servo.write(0); // command to the servo drive - go to the 0 degree position (clockwise movement)
|
|
delay(1000); // wait
|
|
servo.write(90); // stop movement
|
|
delay(1000); // wait
|
|
servo.write(180); // command to the servo drive - move to the 180 degree position (counterclockwise movement)
|
|
delay(1000); // wait
|
|
servo.write(90); // stop movement
|
|
delay(1000); // wait
|
|
}
|