Hi my name is Theo and i have some continue rotation futaba servos from parallax and i'v tried to programm my arduino so to tell in one servo to work for specific time and i failed .I tried the following but i haven't something better.
Code:
do {
digitalWrite(ServoPin,HIGH);
delayMicroseconds(1700);
digitalWrite(ServoPin,LOW);
delay(20);
if(millis() > 5000) {
break;
}
}
while(millis() <= 5000);
If someone can help me write a function to do that please post here and give me directions so to make the function or if you can make the function yourselves and then explain how it works.
Thanks for reading.
Have a look at the Servo library, in particular the "writeMicroseconds" method.
"millis ()" returns the number of millisconds since you reset the Arduino, so after the first five seconds " if(millis() > 5000) {" will always be true. You need to use the difference between the time "now" and the time you decided to start.
Yes i have tried also this one but i remember that i had some problems .
For example when i said to the arduino to start using the servos
arduino did it but the servos were shaking right and left all time while they were working.
I will try it again and i'll tell you the results.
Stay tuned...
but its the same think , i cant control the time the servo is working .
the delay is not the time the servo will work but the time between the pulses .If you know something about it tell me...
To stop your "servo", simply call the "detach" method after the appropriate delay.
This will stop the update pulses.
Call the "attach" method just before you next want to move the "servo"".