I am a newbie in Arduino. Right now, I am trying to control a servo motor with an Arduino and I saw an instruction online like this:
#include //Servo library
Servo servo_test; //initialize a servo object for the connected servo
int angle = 0;
void setup()
{
servo_test.attach(9); // attach the signal pin of servo to pin9 of arduino
}
void loop()
{
for (angle = 0; angle < 180; angle += 1)
{
servo_test.write(angle);
delay(15);
}
delay(1000);
for (angle = 180; angle>=1; angle-=5)
{
servo_test.write(angle);
delay(5);
}
delay(1000);
}
I understand every part of this code, except two lines, which are delay(15)
and delay(5)
. I don't know what the functions of these two lines are. And why 5 and 15 but not both 5 or both 15?