/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-servo-motor
*/
#include <Servo.h>
Servo servo1; // create servo object to control a servo
Servo servo2; // create servo object to control a servo
Servo servo3; // create servo object to control a servo
Servo servo4; // create servo object to control a servo
void setup()
{
servo1.attach(13); // attaches the servo on pin 9 to the servo objectư
servo1.write(0); // rotate slowly servo to 0 degrees immediately
servo2.attach(8); // attaches the servo on pin 9 to the servo objectư
servo2.write(0); // rotate slowly servo to 0 degrees immediately
servo3.attach(7); // attaches the servo on pin 9 to the servo objectư
servo3.write(0); // rotate slowly servo to 0 degrees immediately
servo4.attach(2); // attaches the servo on pin 9 to the servo objectư
servo4.write(0); // rotate slowly servo to 0 degrees immediately
}
int i = 0;
void loop()
{
if (i=0)
{
for (int pos = 0; pos <= 180; pos += 1)
{ // rotate slowly from 0 degrees to 180 degrees, one by one degree
// in steps of 1 degree
servo1.write(pos); // control servo to go to position in variable 'pos'
delay(50); // waits 10ms for the servo to reach the position
}
}
i = i+1;
}
// for (int pos = 180; pos >= 0; pos -= 1)
//{ // rotate from 180 degrees to 0 degrees, one by one degree
//servo1.write(pos); // control servo to go to position in variable 'pos'
//delay(10); // waits 10ms for the servo to reach the position
//}
//for (int pos = 90; pos <= 180; pos += 1)
// { // rotate slowly from 0 degrees to 180 degrees, one by one degree
// in steps of 1 degree
// servo2.write(pos); // control servo to go to position in variable 'pos'
// delay(10); // waits 10ms for the servo to reach the position
// }
//for (int pos = 180; pos >= 90; pos -= 1)
//{ // rotate from 180 degrees to 0 degrees, one by one degree
//servo2.write(pos); // control servo to go to position in variable 'pos'
//delay(10); // waits 10ms for the servo to reach the position
//}
// for (int pos = 0; pos <= 180; pos += 1)
// { // rotate slowly from 0 degrees to 180 degrees, one by one degree
// in steps of 1 degree
// servo3.write(pos); // control servo to go to position in variable 'pos'
// delay(10); // waits 10ms for the servo to reach the position
//}
// for (int pos = 180; pos >= 0; pos -= 1)
// { // rotate from 180 degrees to 0 degrees, one by one degree
// servo3.write(pos); // control servo to go to position in variable 'pos'
// delay(10); // waits 10ms for the servo to reach the position
// }
// for (int pos = 180; pos >= 0; pos -= 1)
// { // rotate from 180 degrees to 0 degrees, one by one degree
// servo4.write(pos); // control servo to go to position in variable 'pos'
// delay(10); // waits 10ms for the servo to reach the position
// }
// for (int pos = 0; pos <= 180; pos += 1)
// { // rotate slowly from 0 degrees to 180 degrees, one by one degree
// in steps of 1 degree
// servo4.write(pos); // control servo to go to position in variable 'pos'
// delay(10); // waits 10ms for the servo to reach the position
// }
// for (int pos = 180; pos >= 0; pos -= 1)
// { // rotate from 180 degrees to 0 degrees, one by one degree
// servo4.write(pos); // control servo to go to position in variable 'pos'
// delay(10); // waits 10ms for the servo to reach the position
// }