As a training exercise in sending digital signals, I am trying to encode a pulse train for a servo without using the servo.h library.
The servo is a micro-servo for 9 g. The hardware is correct, as many examples of using servo.h work fine.
I have the following code. The problem is that the servo control jerks for 3 seconds rather than moving and holding still.
void loop() {
movePulse_1000();
delay(3000);
}
void movePulse_1000(){
Serial.print("Start movePulse_1000()\t\t");
for (int pulseCounter=0; pulseCounter<=150; pulseCounter++){
digitalWrite(pinServo,LOW);
delay(20);
digitalWrite(pinServo,HIGH);
delayMicroseconds(1000);
}
Serial.println("End movePulse_1000()");
}
source
share