/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
*/
// #include <Servo.h>
#include <Servo.h>
// Inner Arms
Servo myservo0;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
// Outer Arms
Servo myservo6;
Servo myservo7;
Servo myservo8;
Servo myservo9;
Servo myservo10;
Servo myservo11;
// Innermost Arms
Servo myservo12;
Servo myservo13;
Servo myservo14;
Servo myservo15;
Servo myservo16;
Servo myservo17;
int pos;
int pos0; // variable to store the servo position
int pos1;
// Servo arr[6] = {myservo0, myservo1, myservo2, myservo3, myservo4, myservo5};
void Stand()
{
for (pos = 45; pos <= 145; pos += 1){
pos0=pos;
pos1=180-pos;
// Inner Arms
myservo0.write(pos0);
myservo1.write(pos0);
myservo2.write(pos0);
myservo3.write(pos1);
myservo4.write(pos1);
myservo5.write(pos1);
// Outer Arms
myservo6.write(pos0+25);
myservo7.write(pos0+25);
myservo8.write(pos0+25);
myservo9.write(pos1-25);
myservo10.write(pos1-25);
myservo11.write(pos1-25);
delay(15);
}
};
void Dance()
{
for (pos = 145; pos >= 45; pos -= 1)
{
pos0=pos;
pos1=180-pos;
myservo0.write(pos0);
myservo1.write(pos0);
myservo2.write(pos0);
myservo3.write(pos1);
myservo4.write(pos1);
myservo5.write(pos1);
delay(15);
// break;
};
for (pos = 45; pos <= 145; pos += 1)
{
pos0=pos;
pos1=180-pos;
myservo0.write(pos0);
myservo1.write(pos0);
myservo2.write(pos0);
myservo3.write(pos1);
myservo4.write(pos1);
myservo5.write(pos1);
delay(15);
};
// for (pos = 45; pos <= 145; pos += 1)
// {
// pos0=pos;
// pos1=180-pos;
// // Inner Arms
// myservo12.write(pos0);
// myservo13.write(pos0);
// myservo14.write(pos0);
// myservo15.write(pos1);
// myservo16.write(pos1);
// myservo17.write(pos1);
// delay(15);
// };
};
void setup()
{
myservo0.attach(2);
myservo1.attach(3);
myservo2.attach(4);
myservo3.attach(5);
myservo4.attach(6);
myservo5.attach(7);
myservo6.attach(8);
myservo7.attach(9);
myservo8.attach(10);
myservo9.attach(11);
myservo10.attach(12);
myservo11.attach(13);
myservo12.attach(24);
myservo13.attach(25);
myservo14.attach(26);
myservo15.attach(27);
myservo16.attach(28);
myservo17.attach(29);
// Stand();
// delay(1000);
};
void loop()
{
Dance();
};