Skip to content

Instantly share code, notes, and snippets.

@raster

raster/ServoSweeps

Created Oct 1, 2020
Embed
What would you like to do?
/*
* ServoSweeps.ino
*
* Testing the BDG Digital I/O Arduino Shield
*
*/
#include <Servo.h>
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;
int pos = 0;
void setup() {
servo2.attach(2);
servo3.attach(3);
servo4.attach(4);
servo5.attach(5);
servo6.attach(6);
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
// tell servo to go to position in variable 'pos'
servo2.write(pos);
servo3.write(pos);
servo4.write(pos);
servo5.write(pos);
servo6.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
// tell servo to go to position in variable 'pos'
servo2.write(pos);
servo3.write(pos);
servo4.write(pos);
servo5.write(pos);
servo6.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.