Hi, I've got a 'hobby' servo that I'm trying to control with the ServoTimeTimer1 library (very similar to the Servo library) but it doesn't seem to work well with the delay() function. Here's the code:
#include <inttypes.h>
#include <avr/io.h>
#include "WProgram.h"
#include <ServoTimeTimer1.h>
#define servoPin1 9
ServoTimeTimer1 servo1;
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
servo1.attach(servoPin1);
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
servo1.write(1600);
delay(3000);
digitalWrite(ledPin, LOW); // sets the LED off
servo1.write(1500);
delay(3000);
}
What happens is that it often moves to the second position and then goes straight back. I guess it's because the servo library uses the same timer as the delay function. Anyone know of a way around this?
Two other small questions:
1. Should the servo vibrate when it is use? Even when it isn't moving? Seems like bad feedback circuitry if it should...
2. Where can I find a reference to all the registers and stuff needed to write things like the Servo library? Is it GCC stuff or is this info provided by Atmel somewhere?
Thanks.