добавлена библиотека servo, прерывание для нее и дефайны по времени

This commit is contained in:
klassents committed 2024-10-03 10:09:18 +07:00
1 parent 63217147e5
commit 2dc71c2171
11 files changed
+943

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
/*
"Broom" Servo
This example demonstrates the servo drive movement
with a smooth stop in both directions
(the example was tested on a servo drive with a circular motion)
*/
#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
}
}