forked from Elron_dev/elbear_arduino_bsp
1 parent
63217147e5
commit
a7468870fc
11 files changed
+938
No files matched your search
@@ -0,0 +1,27 @@
|
||||
|
||||
/*
|
||||
"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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user