Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
1
Indexable
Never
#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

int angle1 = 90;
int angle2 = 90;
int angle3 = 90;
int angle4 = 90;
int angle5 = 90;
int angle6 = 90;

void setup() {
  servo1.attach(2);
  servo2.attach(3);
  servo3.attach(4);
  servo4.attach(5);
  servo5.attach(6);
  servo6.attach(7);

  servo1.write(angle1);
  servo2.write(angle2);
  servo3.write(angle3);
  servo4.write(angle4);
  servo5.write(angle5);
  servo6.write(angle6);

  delay(1000);
}

void loop() {
  angle1 = 90; // decrease angle for servo1 to move arm to right
  angle1 = 0; // increase angle for servo1 to move arm to left
  servo1.write(angle1);

  delay(1000);

  angle2 = 250; // decrease angle for servo2 to move arm up
  angle2 = 0; // increase angle for servo2 to move arm down
  servo2.write(angle2);

  delay(1000);

  angle3 = 180; // decrease angle for servo3 to move arm up
  angle3 = 0; // increase angle for servo3 to move arm down
  servo3.write(angle3);

  delay(1000);

  angle4 = 180; // decrease angle for servo4 to move arm up
  angle4 = 0; // increase angle for servo4 to move arm down
  servo4.write(angle4);

  delay(1000);

  angle5 = 180; // decrease angle for servo5 to move arm up
  angle5 = 0; // increase angle for servo5 to move arm down
  servo5.write(angle5);

  delay(1000);

  angle6 = 180; // decrease angle for servo6 to move arm up
  angle6 = 0; // increase angle for servo6 to move arm down
  servo6.write(angle6);

  delay(5000);
}