elbear_arduino_bsp/libraries/Servo/examples/Broom/Broom.ino
klassents a7468870fc dev_beta_Servo (#3)
Добавлена библиотека Servo
2024-10-03 08:16:43 +03:00

28 lines
888 B
C++

/*
"Broom" Servo
This example demonstrates the servo drive movement
with a smooth stop in both directions
*/
#include <Servo.h>
Servo servo; // create an Servo class instance to control the servo
int pos = 0; // variable for storing servo position
void setup() {
servo.attach(8); // connecting the servo drive to digital pin 8 (D8)
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // change degrees from 0 to 180
servo.write(pos); // command to servo drive - go to position of variable "pos"
delay(15); // waiting for the servo to get there
}
for (pos = 180; pos >= 0; pos -= 1) { // change degrees from 180 to 0
servo.write(pos); // command to servo drive - go to position of variable "pos"
delay(15); // waiting for the servo to get there
}
}