I was testing out my new Servo FS5106B. Here is the code I used:
#include <Servo.h>
Servo servo;
void setup()
{
servo.attach(10);
}
void loop()
{
servo.write(0);
delay(1000);
servo.write(180);
delay(1000);
}
After I upload the sketch, the console says:
Sketch uses 2872 bytes (1%) of your device memory. Total available 253952 bytes. Global variables use 161 bytes (1%) of the dynamic memory, leaving 8031 bytes for local variables. Maximum 8192
The delay between the rotations wasn't 1 second (as I was expecting), but 13 seconds (when I connect only a LED and use the delay function, everything works perfectly). Why is that happening?
P.S The power source for the servo is my Arduino-Mega 2560, wich outputs 5V. The model I use for wiring is:
Edit 1: I tried to execute the program that @ChrisStratton suggested, here an updated code
#include <Servo.h>
#define led 22
Servo servo;
void setup()
{
Serial.begin(9600);
while(!Serial)
delay(10);
Serial.println("Start!");
pinMode(led, OUTPUT);
servo.attach(10);
}
void loop()
{
digitalWrite(led, HIGH);
servo.write(0);
delay(1000);
digitalWrite(led, LOW);
servo.write(180);
delay(1000);
}
When this program loads, servo does 2 rotations in 0.4 seconds and the LED goes high and low really fast, then anything changes for another 10 seconds, then again the LED goes high and low and the Servo does 2 rotations